]> asedeno.scripts.mit.edu Git - git.git/blobdiff - diff-lib.c
Merge branch 'js/commit-format'
[git.git] / diff-lib.c
index ae8364b42a0c67e2461fc20e731417b3203c472f..2e916199066db068d80ff5168b3feee6cfba7056 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) {