gitcancel.sh: ec58f7444a42cd3cbaae919fc68c70a3866420c0 --- gitcancel.sh +++ gitcancel.sh 2005-04-14 10:26:49.000000000 +0200 @@ -12,7 +12,7 @@ # 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 update-cache --refresh gittrack.sh: 03d6db1fb3a70605ef249c632c04e542457f0808 --- gittrack.sh +++ gittrack.sh 2005-04-14 10:26:49.000000000 +0200 @@ -51,6 +51,8 @@ read-tree $(tree-id "$name") gitdiff.sh local "$name" | gitapply.sh + # --update-modes need to be before --refresh + update-cache --update-modes --refresh else [ "$tracking" ] || \ @@ -61,6 +63,8 @@ if [ -s ".git/HEAD.local" ]; then gitdiff.sh "$tracking" local | gitapply.sh read-tree $(tree-id local) + # --update-modes need to be before --refresh + update-cache --update-modes --refresh head=$(cat .git/HEAD) branchhead=$(cat .git/heads/$tracking) show-diff.c: a531ca4078525d1c8dcf84aae0bfa89fed6e5d96 --- show-diff.c +++ show-diff.c 2005-04-14 10:26:49.000000000 +0200 @@ -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; update-cache.c: 62d0a6c41560d40863c44599355af10d9e089312 --- update-cache.c +++ update-cache.c 2005-04-14 10:27:07.000000000 +0200 @@ -210,6 +210,39 @@ } } +static struct cache_entry *update_file_mode(struct cache_entry *ce) +{ + struct stat st; + int changed; + + if (stat(ce->name, &st) < 0) + return NULL; + + changed = cache_match_stat(ce, &st); + if (!changed) + return ce; + + if (changed & MODE_CHANGED) + if (chmod(ce->name, ce->st_mode)) + return NULL; + + return ce; +} + +static void update_modes(void) +{ + int i; + + for (i = 0; i < active_nr; i++) { + struct cache_entry *ce = active_cache[i]; + + if (!update_file_mode(ce)) { + printf("%s: needs update\n", ce->name); + continue; + } + } +} + /* * We fundamentally don't like some paths: we don't want * dot or dot-dot anywhere, and in fact, we don't even want @@ -282,6 +315,10 @@ refresh_cache(); continue; } + if (!strcmp(path, "--update-modes")) { + update_modes(); + continue; + } die("unknown option %s", path); } if (!verify_path(path)) {