gittrack.sh: a9d7c3d117390787e562a0450deb14c7cbf4b565 33 --- a9d7c3d117390787e562a0450deb14c7cbf4b565/gittrack.sh +++ uncommitted/gittrack.sh @@ -49,6 +49,7 @@ read-tree $(tree-id "$name") gitdiff.sh local "$name" | gitapply.sh + update-cache --refresh else [ "$tracking" ] || \ @@ -59,6 +60,7 @@ if [ -s ".git/HEAD.local" ]; then gitdiff.sh "$tracking" local | gitapply.sh read-tree $(tree-id local) + update-cache --refresh head=$(cat .git/HEAD) branchhead=$(cat .git/HEAD.$tracking) show-diff.c: 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc 33 --- 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc/show-diff.c +++ uncommitted/show-diff.c @@ -5,13 +5,18 @@ */ #include "cache.h" -static void show_differences(char *name, +static void show_differences(struct cache_entry *ce, void *old_contents, unsigned long long old_size) { static char cmd[1000]; + static char sha1[41]; + int n; FILE *f; - snprintf(cmd, sizeof(cmd), "diff -L %s -u -N - %s", name, name); + for (n = 0; n < 20; n++) + snprintf(&(sha1[n*2]), 3, "%02x", ce->sha1[n]); + snprintf(cmd, sizeof(cmd), "diff -L %s/%s -L uncommitted/%s -u -N - %s", + sha1, ce->name, ce->name, ce->name); f = popen(cmd, "w"); if (old_size) fwrite(old_contents, old_size, 1, f); @@ -98,7 +103,7 @@ fflush(stdout); new = read_sha1_file(ce->sha1, type, &size); - show_differences(ce->name, new, size); + show_differences(ce, new, size); free(new); } return 0;