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("+++ %s\n", ce->name);
40 printf("@@ -1,%d +0,0 @@\n", lines);
58 int main(int argc, char **argv)
60 int entries = read_cache();
67 for (i = 0; i < entries; i++) {
69 struct cache_entry *ce = active_cache[i];
75 if (stat(ce->name, &st) < 0) {
76 printf("%s: %s\n", ce->name, strerror(errno));
81 changed = cache_match_stat(ce, &st);
84 printf("%.*s: ", ce->namelen, ce->name);
85 for (n = 0; n < 20; n++)
86 printf("%02x", ce->sha1[n]);
89 new = read_sha1_file(ce->sha1, type, &size);
90 show_differences(ce->name, new, size);