From: Junio C Hamano Date: Sat, 7 Jul 2007 20:37:32 +0000 (-0700) Subject: Merge branch 'jc/diff-mark' X-Git-Tag: v1.5.3-rc1~55 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e3c76dbd0f7531eaed3ca8ec0000f03499839304?ds=inline;hp=-c Merge branch 'jc/diff-mark' * jc/diff-mark: diff: honor binariness specified in attributes Fix configuration syntax to specify customized hunk header patterns. Per-path attribute based hunk header selection. Future-proof source for changes in xdemitconf_t Introduce diff_filespec_is_binary() --- e3c76dbd0f7531eaed3ca8ec0000f03499839304 diff --combined builtin-rerere.c index 3196151cc4,01f3848f14..c25b3d5586 --- a/builtin-rerere.c +++ b/builtin-rerere.c @@@ -12,9 -12,6 +12,9 @@@ static const char git_rerere_usage[] static int cutoff_noresolve = 15; static int cutoff_resolve = 60; +/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */ +static int rerere_enabled = -1; + static char *merge_rr_path; static const char *rr_path(const char *name, const char *file) @@@ -285,8 -282,8 +285,8 @@@ static int diff_two(const char *file1, printf("--- a/%s\n+++ b/%s\n", label1, label2); fflush(stdout); xpp.flags = XDF_NEED_MINIMAL; + memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; - xecfg.flags = 0; ecb.outf = outf; xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb); @@@ -390,41 -387,21 +390,41 @@@ static int git_rerere_config(const cha cutoff_resolve = git_config_int(var, value); else if (!strcmp(var, "gc.rerereunresolved")) cutoff_noresolve = git_config_int(var, value); + else if (!strcmp(var, "rerere.enabled")) + rerere_enabled = git_config_bool(var, value); else return git_default_config(var, value); return 0; } -int cmd_rerere(int argc, const char **argv, const char *prefix) +static int is_rerere_enabled(void) { - struct path_list merge_rr = { NULL, 0, 0, 1 }; - int i, fd = -1; struct stat st; + const char *rr_cache; + int rr_cache_exists; - if (stat(git_path("rr-cache"), &st) || !S_ISDIR(st.st_mode)) + if (!rerere_enabled) return 0; + rr_cache = git_path("rr-cache"); + rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode); + if (rerere_enabled < 0) + return rr_cache_exists; + + if (!rr_cache_exists && + (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache))) + die("Could not create directory %s", rr_cache); + return 1; +} + +int cmd_rerere(int argc, const char **argv, const char *prefix) +{ + struct path_list merge_rr = { NULL, 0, 0, 1 }; + int i, fd = -1; + git_config(git_rerere_config); + if (!is_rerere_enabled()) + return 0; merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR")); fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1); @@@ -434,7 -411,6 +434,7 @@@ return do_plain_rerere(&merge_rr, fd); else if (!strcmp(argv[1], "clear")) { for (i = 0; i < merge_rr.nr; i++) { + struct stat st; const char *name = (const char *)merge_rr.items[i].util; if (!stat(git_path("rr-cache/%s", name), &st) && S_ISDIR(st.st_mode) &&