Code

merge-recursive: handle file mode changes
[git.git] / merge-recursive.c
index c292a77a81d137a3ee73111162c9aa515c975d70..d97cbf7d16cd1770229d259a1bfeb179033e5cd8 100644 (file)
@@ -844,8 +844,9 @@ static int read_merge_config(const char *var, const char *value)
        int namelen;
 
        if (!strcmp(var, "merge.default")) {
-               if (value)
-                       default_ll_merge = strdup(value);
+               if (!value)
+                       return config_error_nonbool(var);
+               default_ll_merge = strdup(value);
                return 0;
        }
 
@@ -878,14 +879,14 @@ static int read_merge_config(const char *var, const char *value)
 
        if (!strcmp("name", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                fn->description = strdup(value);
                return 0;
        }
 
        if (!strcmp("driver", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                /*
                 * merge.<name>.driver specifies the command line:
                 *
@@ -908,7 +909,7 @@ static int read_merge_config(const char *var, const char *value)
 
        if (!strcmp("recursive", ep)) {
                if (!value)
-                       return error("%s: lacks value", var);
+                       return config_error_nonbool(var);
                fn->recursive = strdup(value);
                return 0;
        }
@@ -1027,9 +1028,20 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
                if (!sha_eq(a->sha1, o->sha1) && !sha_eq(b->sha1, o->sha1))
                        result.merge = 1;
 
-               result.mode = a->mode == o->mode ? b->mode: a->mode;
+               /*
+                * Merge modes
+                */
+               if (a->mode == b->mode || a->mode == o->mode)
+                       result.mode = b->mode;
+               else {
+                       result.mode = a->mode;
+                       if (b->mode != o->mode) {
+                               result.clean = 0;
+                               result.merge = 1;
+                       }
+               }
 
-               if (sha_eq(a->sha1, o->sha1))
+               if (sha_eq(a->sha1, b->sha1) || sha_eq(a->sha1, o->sha1))
                        hashcpy(result.sha, b->sha1);
                else if (sha_eq(b->sha1, o->sha1))
                        hashcpy(result.sha, a->sha1);