From: Junio C Hamano Date: Sun, 19 May 2019 07:45:35 +0000 (+0900) Subject: Merge branch 'js/difftool-no-index' X-Git-Tag: v2.22.0-rc1~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/fab4a8a39666793d407371f519e8b6d25d33fa84?ds=inline;hp=-c Merge branch 'js/difftool-no-index' The "--dir-diff" mode of "git difftool" is not useful in "--no-index" mode; they are now explicitly marked as mutually incompatible. * js/difftool-no-index: difftool --no-index: error out on --dir-diff (and don't crash) --- fab4a8a39666793d407371f519e8b6d25d33fa84 diff --combined builtin/difftool.c index 53188df714,5704a76088..16eb8b70ea --- a/builtin/difftool.c +++ b/builtin/difftool.c @@@ -24,6 -24,7 +24,6 @@@ #include "object-store.h" #include "dir.h" -static char *diff_gui_tool; static int trust_exit_code; static const char *const builtin_difftool_usage[] = { @@@ -33,6 -34,11 +33,6 @@@ static int difftool_config(const char *var, const char *value, void *cb) { - if (!strcmp(var, "diff.guitool")) { - diff_gui_tool = xstrdup(value); - return 0; - } - if (!strcmp(var, "difftool.trustexitcode")) { trust_exit_code = git_config_bool(var, value); return 0; @@@ -59,12 -65,14 +59,12 @@@ static int parse_index_info(char *p, in *mode2 = (int)strtol(p + 1, &p, 8); if (*p != ' ') return error("expected ' ', got '%c'", *p); - if (get_oid_hex(++p, oid1)) - return error("expected object ID, got '%s'", p + 1); - p += GIT_SHA1_HEXSZ; + if (parse_oid_hex(++p, oid1, (const char **)&p)) + return error("expected object ID, got '%s'", p); if (*p != ' ') return error("expected ' ', got '%c'", *p); - if (get_oid_hex(++p, oid2)) - return error("expected object ID, got '%s'", p + 1); - p += GIT_SHA1_HEXSZ; + if (parse_oid_hex(++p, oid2, (const char **)&p)) + return error("expected object ID, got '%s'", p); if (*p != ' ') return error("expected ' ', got '%c'", *p); *status = *++p; @@@ -727,13 -735,11 +727,14 @@@ int cmd_difftool(int argc, const char * setup_work_tree(); setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1); setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1); - } + } else if (dir_diff) + die(_("--dir-diff is incompatible with --no-index")); - if (use_gui_tool && diff_gui_tool && *diff_gui_tool) - setenv("GIT_DIFF_TOOL", diff_gui_tool, 1); + if (use_gui_tool + !!difftool_cmd + !!extcmd > 1) + die(_("--gui, --tool and --extcmd are mutually exclusive")); + + if (use_gui_tool) + setenv("GIT_MERGETOOL_GUI", "true", 1); else if (difftool_cmd) { if (*difftool_cmd) setenv("GIT_DIFF_TOOL", difftool_cmd, 1);