Code

Handle core.symlinks=false case in merge-recursive.
[git.git] / diff-lib.c
index ae8364b42a0c67e2461fc20e731417b3203c472f..f70888f8af57b3b7a695ecdbc19a3b8bc04c13b2 100644 (file)
@@ -210,11 +210,16 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
        if (revs->max_count == -2) {
                if (revs->diffopt.nr_paths != 2)
                        return error("need two files/directories with --no-index");
-               queue_diff(&revs->diffopt, revs->diffopt.paths[0],
-                               revs->diffopt.paths[1]);
+               if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
+                               revs->diffopt.paths[1]))
+                       return -1;
                diffcore_std(&revs->diffopt);
                diff_flush(&revs->diffopt);
-               return 0;
+               /*
+                * The return code for --no-index imitates diff(1):
+                * 0 = no changes, 1 = changes, else error
+                */
+               return revs->diffopt.found_changes;
        }
 
        if (read_cache() < 0) {
@@ -341,6 +346,9 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
                    S_ISREG(newmode) && S_ISREG(oldmode) &&
                    ((newmode ^ oldmode) == 0111))
                        newmode = oldmode;
+               else if (!has_symlinks &&
+                   S_ISREG(newmode) && S_ISLNK(oldmode))
+                       newmode = oldmode;
                diff_change(&revs->diffopt, oldmode, newmode,
                            ce->sha1, (changed ? null_sha1 : ce->sha1),
                            ce->name, NULL);