* [PATCH 1/4] difftool--helper: Update copyright and remove distracting comments
@ 2010-01-10 4:02 David Aguilar
2010-01-10 4:02 ` [PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable David Aguilar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Aguilar @ 2010-01-10 4:02 UTC (permalink / raw)
To: gitster; +Cc: git, markus.heidelberg
Some of the comments in git-difftool--helper are not needed because
the code is sufficiently readable without them.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool--helper.sh | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 57e8e32..1b13808 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -3,9 +3,8 @@
# This script is typically launched by using the 'git difftool'
# convenience command.
#
-# Copyright (c) 2009 David Aguilar
+# Copyright (c) 2009-2010 David Aguilar
-# Load common functions from git-mergetool--lib
TOOL_MODE=diff
. git-mergetool--lib
@@ -20,7 +19,6 @@ should_prompt () {
fi
}
-# Sets up shell variables and runs a merge tool
launch_merge_tool () {
# Merged is the filename as it appears in the work tree
# Local is the contents of a/filename
@@ -39,7 +37,6 @@ launch_merge_tool () {
read ans
fi
- # Run the appropriate merge tool command
run_merge_tool "$merge_tool"
}
--
1.6.6.4.g20a38b.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable
2010-01-10 4:02 [PATCH 1/4] difftool--helper: Update copyright and remove distracting comments David Aguilar
@ 2010-01-10 4:02 ` David Aguilar
2010-01-10 4:02 ` [PATCH 3/4] difftool: Allow specifying unconfigured commands with --extcmd David Aguilar
2010-01-10 4:02 ` [PATCH 4/4] git-diff.txt: Link to git-difftool David Aguilar
2 siblings, 0 replies; 4+ messages in thread
From: David Aguilar @ 2010-01-10 4:02 UTC (permalink / raw)
To: gitster; +Cc: git, markus.heidelberg
An undocumented mis-feature in git-difftool is that it allows you
to specify a default difftool by setting GIT_MERGE_TOOL.
This behavior was never documented and was included as an
oversight back when git-difftool was maintained outside of git.
git-mergetool never honored GIT_MERGE_TOOL so neither should
git-difftool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool--helper.sh | 9 ++++-----
t/t7800-difftool.sh | 9 ---------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 1b13808..3621f28 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -40,11 +40,10 @@ launch_merge_tool () {
run_merge_tool "$merge_tool"
}
-# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values
-test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL"
-test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL"
-
-if test -z "$merge_tool"; then
+# GIT_DIFF_TOOL indicates that --tool=... was specified
+if test -n "$GIT_DIFF_TOOL"; then
+ merge_tool="$GIT_DIFF_TOOL"
+else
merge_tool="$(get_merge_tool)" || exit
fi
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 9bf6c98..eca51a8 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -32,7 +32,6 @@ restore_test_defaults()
# Restores the test defaults used by several tests
remove_config_vars
unset GIT_DIFF_TOOL
- unset GIT_MERGE_TOOL
unset GIT_DIFFTOOL_PROMPT
unset GIT_DIFFTOOL_NO_PROMPT
git config diff.tool test-tool &&
@@ -107,15 +106,7 @@ test_expect_success 'GIT_DIFF_TOOL overrides' '
git config diff.tool bogus-tool &&
git config merge.tool bogus-tool &&
- GIT_MERGE_TOOL=test-tool &&
- export GIT_MERGE_TOOL &&
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch" &&
- unset GIT_MERGE_TOOL &&
-
- GIT_MERGE_TOOL=bogus-tool &&
GIT_DIFF_TOOL=test-tool &&
- export GIT_MERGE_TOOL &&
export GIT_DIFF_TOOL &&
diff=$(git difftool --no-prompt branch) &&
--
1.6.6.4.g20a38b.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] difftool: Allow specifying unconfigured commands with --extcmd
2010-01-10 4:02 [PATCH 1/4] difftool--helper: Update copyright and remove distracting comments David Aguilar
2010-01-10 4:02 ` [PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable David Aguilar
@ 2010-01-10 4:02 ` David Aguilar
2010-01-10 4:02 ` [PATCH 4/4] git-diff.txt: Link to git-difftool David Aguilar
2 siblings, 0 replies; 4+ messages in thread
From: David Aguilar @ 2010-01-10 4:02 UTC (permalink / raw)
To: gitster; +Cc: git, markus.heidelberg
git-difftool requires difftool.<tool>.cmd configuration even when
tools use the standard "$diffcmd $from $to" form. This teaches
git-difftool to run these tools in lieu of configuration by
allowing the command to be specified on the command line.
Reference: http://article.gmane.org/gmane.comp.version-control.git/133377
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Documentation/git-difftool.txt | 5 +++++
git-difftool--helper.sh | 30 +++++++++++++++++++++++-------
git-difftool.perl | 4 ++++
t/t7800-difftool.sh | 19 ++++++++++++++++++-
4 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index a5bce62..f67d2db 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -58,6 +58,11 @@ is set to the name of the temporary file containing the contents
of the diff post-image. `$BASE` is provided for compatibility
with custom merge tool commands and has the same value as `$LOCAL`.
+--extcmd=<command>::
+ Specify a custom command for viewing diffs.
+ 'git-difftool' ignores the configured defaults and runs
+ `$command $LOCAL $REMOTE` when this option is specified.
+
-g::
--gui::
When 'git-difftool' is invoked with the `-g` or `--gui` option
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 3621f28..d806eae 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -19,6 +19,11 @@ should_prompt () {
fi
}
+# Indicates that --extcmd=... was specified
+use_ext_cmd () {
+ test -n "$GIT_DIFFTOOL_EXTCMD"
+}
+
launch_merge_tool () {
# Merged is the filename as it appears in the work tree
# Local is the contents of a/filename
@@ -33,18 +38,29 @@ launch_merge_tool () {
# the user with the real $MERGED name before launching $merge_tool.
if should_prompt; then
printf "\nViewing: '$MERGED'\n"
- printf "Hit return to launch '%s': " "$merge_tool"
+ if use_ext_cmd; then
+ printf "Hit return to launch '%s': " \
+ "$GIT_DIFFTOOL_EXTCMD"
+ else
+ printf "Hit return to launch '%s': " "$merge_tool"
+ fi
read ans
fi
- run_merge_tool "$merge_tool"
+ if use_ext_cmd; then
+ $GIT_DIFFTOOL_EXTCMD "$LOCAL" "$REMOTE"
+ else
+ run_merge_tool "$merge_tool"
+ fi
+
}
-# GIT_DIFF_TOOL indicates that --tool=... was specified
-if test -n "$GIT_DIFF_TOOL"; then
- merge_tool="$GIT_DIFF_TOOL"
-else
- merge_tool="$(get_merge_tool)" || exit
+if ! use_ext_cmd; then
+ if test -n "$GIT_DIFF_TOOL"; then
+ merge_tool="$GIT_DIFF_TOOL"
+ else
+ merge_tool="$(get_merge_tool)" || exit
+ fi
fi
# Launch the merge tool on each path provided by 'git diff'
diff --git a/git-difftool.perl b/git-difftool.perl
index 8c836e4..f8ff245 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -62,6 +62,10 @@ sub generate_command
$skip_next = 1;
next;
}
+ if ($arg =~ /^--extcmd=/) {
+ $ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);
+ next;
+ }
if ($arg =~ /^--tool=/) {
$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
next;
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index eca51a8..8ee186a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -214,7 +214,24 @@ test_expect_success 'difftool.<tool>.path' '
diff=$(git difftool --tool=tkdiff --no-prompt branch) &&
git config --unset difftool.tkdiff.path &&
lines=$(echo "$diff" | grep file | wc -l) &&
- test "$lines" -eq 1
+ test "$lines" -eq 1 &&
+
+ restore_test_defaults
+'
+
+test_expect_success 'difftool --extcmd=...' '
+ diff=$(git difftool --no-prompt --extcmd=cat branch) &&
+
+ lines=$(echo "$diff" | wc -l) &&
+ test "$lines" -eq 2 &&
+
+ lines=$(echo "$diff" | grep master | wc -l) &&
+ test "$lines" -eq 1 &&
+
+ lines=$(echo "$diff" | grep branch | wc -l) &&
+ test "$lines" -eq 1 &&
+
+ restore_test_defaults
'
test_done
--
1.6.6.4.g20a38b.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] git-diff.txt: Link to git-difftool
2010-01-10 4:02 [PATCH 1/4] difftool--helper: Update copyright and remove distracting comments David Aguilar
2010-01-10 4:02 ` [PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable David Aguilar
2010-01-10 4:02 ` [PATCH 3/4] difftool: Allow specifying unconfigured commands with --extcmd David Aguilar
@ 2010-01-10 4:02 ` David Aguilar
2 siblings, 0 replies; 4+ messages in thread
From: David Aguilar @ 2010-01-10 4:02 UTC (permalink / raw)
To: gitster; +Cc: git, markus.heidelberg
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Documentation/git-diff.txt | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 0ac7112..723a648 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -157,6 +157,10 @@ $ git diff -R <2>
rewrites (very expensive).
<2> Output diff in reverse.
+SEE ALSO
+--------
+linkgit:git-difftool[1]::
+ Show changes using common diff tools
Author
------
--
1.6.6.4.g20a38b.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-01-10 4:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 4:02 [PATCH 1/4] difftool--helper: Update copyright and remove distracting comments David Aguilar
2010-01-10 4:02 ` [PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable David Aguilar
2010-01-10 4:02 ` [PATCH 3/4] difftool: Allow specifying unconfigured commands with --extcmd David Aguilar
2010-01-10 4:02 ` [PATCH 4/4] git-diff.txt: Link to git-difftool David Aguilar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).