git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] difftool --no-index: error out on --dir-diff (and don't crash)

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
May 8, 2019, 21:52 UTC
Message-ID
<9f2ee5ef0b84b348d07fedc47fced8d4772a9c43.1557352359.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.186.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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 <johannes.schindelin@gmx.de>
---
 builtin/difftool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 4fff1e83f9..5704a76088 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -735,7 +735,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);
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 2 of 3 in “difftool: --no-index is incompatible with --dir-diff”
  1. 0/1 difftool: --no-index is incompatible with --dir-diffJohannes Schindelin via GitGitGadget, May 8, 2019
  2. 1/1 difftool --no-index: error out on --dir-diff (and don't crash)Johannes Schindelin via GitGitGadget, May 8, 2019
  3. Junio C HamanoMay 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.