2 * GIT - The information manager from hell
4 * Copyright (C) Linus Torvalds, 2005
8 static void show_differences(char *name,
9 void *old_contents, unsigned long long old_size)
11 static char cmd[1000];
14 snprintf(cmd, sizeof(cmd), "diff -L %s -u -N - %s", name, name);
17 fwrite(old_contents, old_size, 1, f);
21 static void show_diff_empty(struct cache_entry *ce)
24 unsigned long int size;
26 unsigned char type[20], *p, *end;
28 old = read_sha1_file(ce->sha1, type, &size);
33 printf("--- %s\n", ce->name);
34 printf("+++ /dev/null\n");
40 printf("@@ -1,%d +0,0 @@\n", lines);
58 int main(int argc, char **argv)
61 int entries = read_cache();
65 if (!strcmp(argv[1], "-s")) {
69 usage("show-diff [-s]");
76 for (i = 0; i < entries; i++) {
78 struct cache_entry *ce = active_cache[i];
84 if (stat(ce->name, &st) < 0) {
85 printf("%s: %s\n", ce->name, strerror(errno));
86 if (errno == ENOENT && !silent)
90 changed = cache_match_stat(ce, &st);
93 printf("%.*s: ", ce->namelen, ce->name);
94 for (n = 0; n < 20; n++)
95 printf("%02x", ce->sha1[n]);
101 new = read_sha1_file(ce->sha1, type, &size);
102 show_differences(ce->name, new, size);