git apply patch解决冲突

网上看了一些解决patch的方法,例如:http://blog.sina.com.cn/s/blog_5372b1a301015y0n.html

当使用git apply --reject patch后生成.rej, 但是.rej到底里面是什么东东?到底自己的文件修改了多少呢?让我们来看看!


$ git status
# Not currently on any branch.
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:   Android.mk
#       modified:   api/current.txt
#       modified:   core/java/android/app/ContextImpl.java
#       modified:   core/java/android/content/Context.java
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       Android.mk.rej
#       api/current.txt.rej
#       core/java/android/app/ContextImpl.java.rej
#       core/java/android/content/Context.java.rej
#       frameworks_base.diff
#       services/java/Android.mk.rej
#       services/java/com/android/server/SystemServer.java.rej


吼吼~~~这么多.rej文件,你会看到modified的文件和.rej的文件有重复,那修改了什么呢?.rej里面是什么呢?

用下面的方法一探究竟吧。

1. git diff看看modified的文件

diff --git a/api/current.txt b/api/current.txt

index 8e69592..cafb124 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6007,6 +6007,8 @@ package android.content {
     field public static final java.lang.String SEARCH_SERVICE = "search";
     field public static final java.lang.String SENSOR_SERVICE = "sensor";
     field public static final java.lang.String STORAGE_SERVICE = "storage";
+    field public static final java.lang.String SAMPLE_SERVICE = "SampleService";
+    field public static final java.lang.String SAMPLE_SERVICE_INTENT = "com.sample.service.SampleService";
     field public static final java.lang.String TELEPHONY_SERVICE = "phone";
     field public static final java.lang.String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
     field public static final java.lang.String UI_MODE_SERVICE = "uimode";

2. cat api/current.txt

diff a/api/current.txt b/api/current.txt        (rejected hunks)
@@ -6007,6 +6007,8 @@ package android.content {
     field public static final java.lang.String SEARCH_SERVICE = "search";
     field public static final java.lang.String SENSOR_SERVICE = "sensor";
     field public static final java.lang.String STORAGE_SERVICE = "storage";
+    field public static final java.lang.String SAMPLE_SERVICE = "SampleService";
+    field public static final java.lang.String SAMPLE_SERVICE_INTENT = "com.sample.service.SampleService";
     field public static final java.lang.String TELEPHONY_SERVICE = "phone";
     field public static final java.lang.String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
     field public static final java.lang.String UI_MODE_SERVICE = "uimode";


现在知道了.rej就是表示你修改了什么,而修改内容已经在源文件了!

但是……services/java/Android.mk.rej和services/java/com/android/server/SystemServer.java.rej这两个并没有修改文件!这是……???

直接公布答案!

这两个文件修改已经包含了,没有修改!但是你得patch表示还是有修改的,所以生成.rej标明修改了哪些东西!


总结:

1. 能够直接修改的,就修改了,但是生成.rej标明修改了哪些东东。

2. 不能修改的或者不用修改的,直接只生成.rej来告诉你,这些东东没有修改,你看着办吧!


如果有哪些错误,欢迎指正!

转载请注明出处!

来源:http://blog.csdn.net/lizzywu/article/details/18669841

你可能感兴趣的:(Android)