checkout-cache.c: f06871cdbc1b18ea93bdf4e17126aeb4cca1373e --- f06871cdbc1b18ea93bdf4e17126aeb4cca1373e/checkout-cache.c +++ uncommitted/checkout-cache.c @@ -34,7 +34,7 @@ */ #include "cache.h" -static int force = 0, quiet = 0; +static int force = 0, quiet = 0, update_mode = 0; static void create_directories(const char *path) { @@ -99,6 +99,8 @@ unsigned changed = cache_match_stat(ce, &st); if (!changed) return 0; + if (update_mode && changed & MODE_CHANGED) + chmod(ce->name, ce->st_mode); if (!force) { if (!quiet) fprintf(stderr, "checkout-cache: %s already exists\n", ce->name); @@ -158,6 +160,10 @@ quiet = 1; continue; } + if (!strcmp(arg, "-m")) { + update_mode = 1; + continue; + } } checkout_file(arg); } gitcancel.sh: ec58f7444a42cd3cbaae919fc68c70a3866420c0 --- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh +++ uncommitted/gitcancel.sh @@ -12,7 +12,8 @@ # FIXME: Does not revert mode changes! -show-diff | patch -p0 -R +show-diff | patch -p1 -R rm -f .git/add-queue .git/rm-queue .git/merged +checkout-cache -q -m -a update-cache --refresh gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808 --- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh +++ uncommitted/gittrack.sh @@ -51,6 +51,8 @@ read-tree $(tree-id "$name") gitdiff.sh local "$name" | gitapply.sh + checkout-cache -q -m -a + update-cache --refresh else [ "$tracking" ] || \ @@ -61,6 +63,8 @@ if [ -s ".git/HEAD.local" ]; then gitdiff.sh "$tracking" local | gitapply.sh read-tree $(tree-id local) + checkout-cache -q -m -a + update-cache --refresh head=$(cat .git/HEAD) branchhead=$(cat .git/heads/$tracking) show-diff.c: a531ca4078525d1c8dcf84aae0bfa89fed6e5d96 --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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); @@ -99,7 +104,7 @@ continue; new = read_sha1_file(ce->sha1, type, &size); - show_differences(ce->name, new, size); + show_differences(ce, new, size); free(new); } return 0;