Code

[PATCH] Do not run useless show-diff on unmerged paths repeatedly.
authorJunio C Hamano <junkio@cox.net>
Sun, 17 Apr 2005 04:29:45 +0000 (21:29 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 17 Apr 2005 04:29:45 +0000 (21:29 -0700)
When run on unmerged dircache, show-diff compares the working
file with each non-empty stage for that path.  Two out of three
times, this is not very helpful.  This patch makes it report the
unmergedness only once per each path and avoids running the
actual diff.

Upper layer SCMs like Cogito are expected to find out mode/SHA1
for each stage by using "show-files --stage" and run the diff
itself.  This would result in more sensible diffs.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
show-diff.c

index 1f903af0279a545c1c679892a8a94a53d3dc162d..0af2f1051e4886277af3d55257d0dfd5bd2ca2e6 100644 (file)
@@ -167,6 +167,19 @@ int main(int argc, char **argv)
                    ! matches_pathspec(ce, argv+1, argc-1))
                        continue;
 
+               if (ce_stage(ce)) {
+                       if (machine_readable)
+                               printf("U %s%c", ce->name, 0);
+                       else
+                               printf("%s: Unmerged\n",
+                                      ce->name);
+                       while (i < entries &&
+                              !strcmp(ce->name, active_cache[i]->name))
+                               i++;
+                       i--; /* compensate for loop control increments */
+                       continue;
+               }
                if (stat(ce->name, &st) < 0) {
                        if (errno == ENOENT && silent_on_nonexisting_files)
                                continue;