Code

[PATCH] show-diff.c: do not include unused header file
[git.git] / show-diff.c
index f2d352f4e6e36e1a69710ecdd4c2f5e615065781..8a66e59cf5f6e05dd5944e479f95a2a12a6ccf95 100644 (file)
@@ -4,7 +4,6 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 #include "cache.h"
-#include <ctype.h>
 
 static char *diff_cmd = "diff -L '%s' -u -N  - '%s'";
 
@@ -111,7 +110,7 @@ static void show_diff_empty(struct cache_entry *ce)
        }
 }
 
-static const char *show_diff_usage = "show-diff [-s] [-q] [-z] [paths...]";
+static const char *show_diff_usage = "show-diff [-q] [-s] [-z] [paths...]";
 
 static int matches_pathspec(struct cache_entry *ce, char **spec, int cnt)
 {
@@ -141,9 +140,8 @@ int main(int argc, char **argv)
                        silent_on_nonexisting_files = silent = 1;
                else if (!strcmp(argv[1], "-q"))
                        silent_on_nonexisting_files = 1;
-               else if (!strcmp(argv[1], "-z")) {
+               else if (!strcmp(argv[1], "-z"))
                        machine_readable = 1;
-               }
                else
                        usage(show_diff_usage);
                argv++; argc--;
@@ -162,12 +160,25 @@ int main(int argc, char **argv)
                int changed;
                unsigned long size;
                char type[20];
-               void *new;
+               void *old;
 
-               if (1 <argc &&
+               if (1 < argc &&
                    ! 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;
@@ -193,9 +204,9 @@ int main(int argc, char **argv)
                if (silent)
                        continue;
 
-               new = read_sha1_file(ce->sha1, type, &size);
-               show_differences(ce->name, new, size);
-               free(new);
+               old = read_sha1_file(ce->sha1, type, &size);
+               show_differences(ce->name, old, size);
+               free(old);
        }
        return 0;
 }