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

[PATCH 2/2] difftool: provide basename to external tools

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Dec 14, 2010, 09:18 UTC
Message-ID
<3a5944cb9af7b6b69dc0bdefdfd052b33fcd9a59.1292317348.git.git@drmicha.warpmail.net>
In-Reply-To
<4D073619.2010103@drmicha.warpmail.net>

Currently, only configured diff helpers get the basename of the file being compared. Tools specified with "git difftool -x" only get the names of temporary files for the different versions.

Export BASE so that an external tool can read the name from the environment. Rather than using a third argument, this avoids breaking existing scripts which may somewhat carelessly be using "$@" rather than "$1" "$2".

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-difftool.txt |    1 +
 git-difftool--helper.sh        |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 756d95d..db87f1d 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -65,6 +65,7 @@ with custom merge tool commands and has the same value as `$MERGED`.
 	Specify a custom command for viewing diffs.
 	'git-difftool' ignores the configured defaults and runs
 	`$command $LOCAL $REMOTE` when this option is specified.
+	Additionally, `$BASE` is set in the environment.
 
 -g::
 --gui::
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 524f5ea..0594bf7 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -49,6 +49,7 @@ launch_merge_tool () {
 	fi
 
 	if use_ext_cmd; then
+		export BASE
 		eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
 	else
 		run_merge_tool "$merge_tool"
-- 
1.7.3.3.739.g52f77.dirty
Previous: Michael J GruberNext: Seshu Parvataneni
Message 4 of 5 in “how to create a diff in old file new file format (for code reviews)”
  1. aerosmithDec 14, 2010
  2. Michael J GruberDec 14, 2010
  3. 1/2 git-difftool.txt: correct the description of $BASE and describe $MERGEDMichael J Gruber, Dec 14, 2010
  4. 2/2 difftool: provide basename to external toolsMichael J Gruber, Dec 14, 2010
  5. Seshu ParvataneniDec 16, 2010

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.