From 2c5d00a2e9a168df09339a594878fb262828afb9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 29 Apr 2019 20:50:38 -0400 Subject: [PATCH] difftool --no-index: error out on --dir-diff (and don't crash) In `--no-index` mode, we now no longer require a worktree nor a repository. But some code paths in `difftool` expect those to be present. The most notable such code path is the `--dir-diff` one: we use the existing checkout machinery to copy the files, and that machinery looks up replacement refs, looks at alternate ODBs, wants to use the worktree path, etc. Rather than running into segmentation faults, let's die with an informative error message. Signed-off-by: Johannes Schindelin --- builtin/difftool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/difftool.c b/builtin/difftool.c index 04ffa1d943..e866b8ed30 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -733,7 +733,8 @@ int cmd_difftool(int argc, const char **argv, const char *prefix) 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);