* git-difftool
@ 2008-12-26 1:30 David Aguilar
2008-12-31 16:04 ` git-difftool Matthieu Moy
0 siblings, 1 reply; 16+ messages in thread
From: David Aguilar @ 2008-12-26 1:30 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]
Several co-workers have found this script useful.
It's basically git-mergetool modified to operate on the git
index/worktree. There's some things about the script that
aren't very gitish (for example, the way revargs are
processed) but it's useful nonetheless.
The usual use case for this script is when you have either
staged or unstaged changes and you'd like to see the changes
in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
git difftool [<filename>*]
Another use case is when you'd like to see the same
information but are comparing arbitrary commits
(this is the part where the revarg parsing could be better)
git difftool --start=HEAD^ --end=HEAD [-- <filename>*]
The last use case is when you'd like to compare your current
worktree to something other than HEAD (e.g. a tag)
git difftool --commit=v1.0.0 [-- <filename>*]
It's a generally useful script so I thought I'd share it here.
If others find it useful then maybe we can fix it up and ship
it along with the other useful goodies in contrib/.
enjoy,
--
David
[-- Attachment #2: git-difftool.sh --]
[-- Type: application/x-sh, Size: 12218 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2008-12-26 1:30 git-difftool David Aguilar
@ 2008-12-31 16:04 ` Matthieu Moy
2008-12-31 20:11 ` git-difftool David Aguilar
2009-01-01 7:38 ` git-difftool Ping Yin
0 siblings, 2 replies; 16+ messages in thread
From: Matthieu Moy @ 2008-12-31 16:04 UTC (permalink / raw)
To: David Aguilar; +Cc: git
David Aguilar <davvid@gmail.com> writes:
> The usual use case for this script is when you have either
> staged or unstaged changes and you'd like to see the changes
> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
>
> git difftool [<filename>*]
Is it not a complex way of saying
GIT_EXTERNAL_DIFF=xxdiff git diff
?
(My 2 cents, and happy new year ;-)
--
Matthieu
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2008-12-31 16:04 ` git-difftool Matthieu Moy
@ 2008-12-31 20:11 ` David Aguilar
2008-12-31 21:20 ` git-difftool Boyd Stephen Smith Jr.
2009-01-01 17:58 ` git-difftool Matthieu Moy
2009-01-01 7:38 ` git-difftool Ping Yin
1 sibling, 2 replies; 16+ messages in thread
From: David Aguilar @ 2008-12-31 20:11 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git
On Wed, Dec 31, 2008 at 8:04 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> David Aguilar <davvid@gmail.com> writes:
>
>> The usual use case for this script is when you have either
>> staged or unstaged changes and you'd like to see the changes
>> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
>>
>> git difftool [<filename>*]
>
> Is it not a complex way of saying
>
> GIT_EXTERNAL_DIFF=xxdiff git diff
>
> ?
>
> (My 2 cents, and happy new year ;-)
>
> --
> Matthieu
>
Hmm... in theory, yes, but in practice, no.
xxdiff is too gimp to handle what 'git diff' hands it =)
For example:
$ GIT_EXTERNAL_DIFF=echo git diff test
test /tmp/.diff_1dh4TW 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 100644 test 0000
$ GIT_EXTERNAL_DIFF=xxdiff git diff test
xxdiff (cmdline.cpp:762):
You can specify at most 3 filenames.
Extra arguments: " 100644 test 0000000000000000000000000000000000000000 100644"
Use 'xxdiff --help' for more information.
external diff died, stopping at test.
I checked the git-diff documentation and could not find a way to
inhibit the sha1, mode, etc. args that are sent to GIT_EXTERNAL_DIFF
(nor should there be, I presume).
I'm all for finding the simplest way and GIT_EXTERNAL_DIFF seems like
the right entry point. What I should do is change the script so that
it handles all of the choosing-a-merge-tool-logic and just have git
call it via GIT_EXTERNAL_DIFF. That would definitely simplify the
script since 'git diff' would be handling all of the tmp file and
option processing logic. wow, I really like that idea. Thanks for
the tip!
Happy new year,
--
David
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2008-12-31 20:11 ` git-difftool David Aguilar
@ 2008-12-31 21:20 ` Boyd Stephen Smith Jr.
2009-01-01 17:58 ` git-difftool Matthieu Moy
1 sibling, 0 replies; 16+ messages in thread
From: Boyd Stephen Smith Jr. @ 2008-12-31 21:20 UTC (permalink / raw)
To: David Aguilar; +Cc: git, Matthieu Moy
[-- Attachment #1: Type: text/plain, Size: 981 bytes --]
On Wednesday 2008 December 31 14:11:07 you wrote:
> On Wed, Dec 31, 2008 at 8:04 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> > David Aguilar <davvid@gmail.com> writes:
> >> The usual use case for this script is when you have either
> >> staged or unstaged changes and you'd like to see the changes
> >> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
> >>
> >> git difftool [<filename>*]
> >
> > Is it not a complex way of saying
> >
> > GIT_EXTERNAL_DIFF=xxdiff git diff
> >
> > ?
>
> Hmm... in theory, yes, but in practice, no.
> xxdiff is too gimp to handle what 'git diff' hands it =)
What about something like:
git diff | xxdiff -
I normally use:
git diff | kompare -
and it works fine.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2008-12-31 16:04 ` git-difftool Matthieu Moy
2008-12-31 20:11 ` git-difftool David Aguilar
@ 2009-01-01 7:38 ` Ping Yin
2009-01-02 0:04 ` git-difftool Markus Heidelberg
1 sibling, 1 reply; 16+ messages in thread
From: Ping Yin @ 2009-01-01 7:38 UTC (permalink / raw)
To: Matthieu Moy; +Cc: David Aguilar, git
On Thu, Jan 1, 2009 at 12:04 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> David Aguilar <davvid@gmail.com> writes:
>
>> The usual use case for this script is when you have either
>> staged or unstaged changes and you'd like to see the changes
>> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
>>
>> git difftool [<filename>*]
>
> Is it not a complex way of saying
>
> GIT_EXTERNAL_DIFF=xxdiff git diff
$ cat mydiff
#!/bin/bash
exec vimdiff $2 $5
then i run
$ GIT_EXTERNAL_DIFF=mydiff git diff
but it gives me the error
Vim: Warning: Output is not to a terminal
$ ps -ef | grep vimdiff
ping 20284 20283 1 15:37 pts/13 00:00:00 vimdiff
/tmp/.diff_XXXQK6 index.php
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2008-12-31 20:11 ` git-difftool David Aguilar
2008-12-31 21:20 ` git-difftool Boyd Stephen Smith Jr.
@ 2009-01-01 17:58 ` Matthieu Moy
2009-01-02 0:13 ` git-difftool Markus Heidelberg
1 sibling, 1 reply; 16+ messages in thread
From: Matthieu Moy @ 2009-01-01 17:58 UTC (permalink / raw)
To: David Aguilar; +Cc: git
"David Aguilar" <davvid@gmail.com> writes:
> Hmm... in theory, yes, but in practice, no.
> xxdiff is too gimp to handle what 'git diff' hands it =)
As done with "vimdiff" in another message, simply write a one-liner
wrapper script that calls xxdiff $2 $3, and call this wrapper script.
--
Matthieu
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-01 7:38 ` git-difftool Ping Yin
@ 2009-01-02 0:04 ` Markus Heidelberg
2009-01-02 1:59 ` git-difftool Ping Yin
0 siblings, 1 reply; 16+ messages in thread
From: Markus Heidelberg @ 2009-01-02 0:04 UTC (permalink / raw)
To: Ping Yin; +Cc: Matthieu Moy, David Aguilar, git
Ping Yin, 01.01.2009:
> On Thu, Jan 1, 2009 at 12:04 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> > David Aguilar <davvid@gmail.com> writes:
> >
> >> The usual use case for this script is when you have either
> >> staged or unstaged changes and you'd like to see the changes
> >> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
> >>
> >> git difftool [<filename>*]
> >
> > Is it not a complex way of saying
> >
> > GIT_EXTERNAL_DIFF=xxdiff git diff
>
> $ cat mydiff
> #!/bin/bash
> exec vimdiff $2 $5
>
> then i run
>
> $ GIT_EXTERNAL_DIFF=mydiff git diff
>
> but it gives me the error
> Vim: Warning: Output is not to a terminal
Just the warning and everything else works? For me the display is
totally screwed up and the commands don't really work because of the
pager. I have to add GIT_PAGER="" to get it working.
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-01 17:58 ` git-difftool Matthieu Moy
@ 2009-01-02 0:13 ` Markus Heidelberg
2009-01-02 16:10 ` git-difftool Matthieu Moy
0 siblings, 1 reply; 16+ messages in thread
From: Markus Heidelberg @ 2009-01-02 0:13 UTC (permalink / raw)
To: Matthieu Moy; +Cc: David Aguilar, git
Matthieu Moy, 01.01.2009:
> "David Aguilar" <davvid@gmail.com> writes:
>
> > Hmm... in theory, yes, but in practice, no.
> > xxdiff is too gimp to handle what 'git diff' hands it =)
>
> As done with "vimdiff" in another message, simply write a one-liner
> wrapper script that calls xxdiff $2 $3, and call this wrapper script.
This works with GUI tools, but not with console tools. GVim works, Vim
doesn't.
And invoking
git difftool
is by far more convenient than
GIT_EXTERNAL_DIFF=vimdiff git diff
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-02 0:04 ` git-difftool Markus Heidelberg
@ 2009-01-02 1:59 ` Ping Yin
2009-01-17 3:47 ` git-difftool enso
0 siblings, 1 reply; 16+ messages in thread
From: Ping Yin @ 2009-01-02 1:59 UTC (permalink / raw)
To: markus.heidelberg; +Cc: Matthieu Moy, David Aguilar, git
On Fri, Jan 2, 2009 at 8:04 AM, Markus Heidelberg
<markus.heidelberg@web.de> wrote:
> Ping Yin, 01.01.2009:
>> On Thu, Jan 1, 2009 at 12:04 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
>> > David Aguilar <davvid@gmail.com> writes:
>> >
>> >> The usual use case for this script is when you have either
>> >> staged or unstaged changes and you'd like to see the changes
>> >> in a side-by-side diff viewer (e.g. xxdiff, tkdiff, etc).
>> >>
>> >> git difftool [<filename>*]
>> >
>> > Is it not a complex way of saying
>> >
>> > GIT_EXTERNAL_DIFF=xxdiff git diff
>>
>> $ cat mydiff
>> #!/bin/bash
>> exec vimdiff $2 $5
>>
>> then i run
>>
>> $ GIT_EXTERNAL_DIFF=mydiff git diff
>>
>> but it gives me the error
>> Vim: Warning: Output is not to a terminal
>
> Just the warning and everything else works? For me the display is
> totally screwed up and the commands don't really work because of the
> pager. I have to add GIT_PAGER="" to get it working.
>
Thanks. With GIT_PAGER="" it works now.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-02 0:13 ` git-difftool Markus Heidelberg
@ 2009-01-02 16:10 ` Matthieu Moy
2009-01-02 17:39 ` git-difftool David Aguilar
0 siblings, 1 reply; 16+ messages in thread
From: Matthieu Moy @ 2009-01-02 16:10 UTC (permalink / raw)
To: markus.heidelberg; +Cc: David Aguilar, git
Markus Heidelberg <markus.heidelberg@web.de> writes:
> Matthieu Moy, 01.01.2009:
>> "David Aguilar" <davvid@gmail.com> writes:
>>
>> > Hmm... in theory, yes, but in practice, no.
>> > xxdiff is too gimp to handle what 'git diff' hands it =)
>>
>> As done with "vimdiff" in another message, simply write a one-liner
>> wrapper script that calls xxdiff $2 $3, and call this wrapper script.
>
> This works with GUI tools, but not with console tools.
Actually, it does if you call git --no-pager.
> GVim works, Vim
> doesn't.
> And invoking
> git difftool
> is by far more convenient than
> GIT_EXTERNAL_DIFF=vimdiff git diff
Right, but a script "git-difftool" calling the later is a one-liner,
so 2 one-liners give you the same result as the ~500 lines script
proposed. And GIT_EXTERNAL_DIFF has the great advantage of being
maintained together with git, and will most likely handle all cases
(diff between index, working tree, arbitrary commit, ...) correctly.
--
Matthieu
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-02 16:10 ` git-difftool Matthieu Moy
@ 2009-01-02 17:39 ` David Aguilar
2009-01-15 22:26 ` git-difftool Markus Heidelberg
0 siblings, 1 reply; 16+ messages in thread
From: David Aguilar @ 2009-01-02 17:39 UTC (permalink / raw)
To: Matthieu Moy; +Cc: markus.heidelberg, git
[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]
On Fri, Jan 2, 2009 at 8:10 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
>
> As done with "vimdiff" in another message, simply write a
> one-liner wrapper script that calls xxdiff $2 $3, and call this
> wrapper script.
>
> ...
>
> Right, but a script "git-difftool" calling the later is a one-liner,
> so 2 one-liners give you the same result as the ~500 lines script
> proposed. And GIT_EXTERNAL_DIFF has the great advantage
> of being maintained together with git, and will most likely handle
> all cases (diff between index, working tree, arbitrary commit, ...)
> correctly.
>
> --
> Matthieu
>
Thanks for the feedback. I've done exactly what you suggested.
I now have a git-difftool wrapper script that basically just sets up
the environment for git-difftool-helper. git-difftool-helper does all
of the merge tool configuration stuff ala
http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html (it
uses the same git config variables and thus works with existing custom
commands). If you drop them both into the same directory it should
work as-is (it munges $PATH).
It's not a two-liner (they do all that git config stuff and handle
more than just vimdiff) but it does use GIT_EXTERNAL_DIFF now, which
makes the script infinitely more useful. This is much nicer now since
you can pass any 'git diff' options to git-difftool and it'll handle
it correctly.
The usage is simpler now too:
usage: git difftool [--no-prompt] [--tool=tool] ["git diff" options]
Thanks for your help,
--
David
[-- Attachment #2: git-difftool --]
[-- Type: application/octet-stream, Size: 1876 bytes --]
#!/usr/bin/env perl
# This is a wrapper around the GIT_EXTERNAL_DIFF compatible
# git-difftool-helper script.
#
# Copyright (c) 2009 David Aguilar
use strict;
use warnings;
use File::Basename qw(dirname);
# Prints usage and exits
sub usage
{
print << 'USAGE';
usage: git difftool [--no-prompt] [--tool=tool] ["git diff" options]
USAGE
exit 1;
}
# Sets PATH, GIT_PAGER, and GIT_EXTERNAL_DIFF so that
# git-difftool-helper is invoked by 'git diff'.
sub setup_environment
{
my @paths = ( dirname($0), split(':', $ENV{PATH}) );
$ENV{PATH} = join(':', @paths);
$ENV{GIT_PAGER} = '';
$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool-helper';
}
# Sets an environment variable recognized by git-difftool-helper
# to signal that we shouldn't prompt before viewing each file.
sub no_prompt
{
$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
}
# Sets a default value for the merge tool used by git-difftool-helper.
sub setup_mergetool
{
$ENV{GIT_MERGE_TOOL} = shift;
}
# Processes command-line flags and generates a corresponding
# 'git diff' command. Any arguments that are unknown to this
# script are assumed to be arguments intended for 'git diff'.
sub generate_command
{
my @command = ('git', 'diff');
my $skip_next = 0;
my $idx = -1;
for my $arg (@ARGV) {
$idx++;
if ($skip_next) {
$skip_next = 0;
next;
}
if ($arg eq '-h' or $arg eq '--help') {
usage()
}
if ($arg eq '--no-prompt') {
no_prompt();
next;
}
if ($arg eq '-t' or $arg eq '--tool') {
$skip_next = 1;
if ( scalar(@ARGV) <= $idx + 1 ) {
usage();
}
setup_mergetool($ARGV[$idx + 1]);
next;
}
if ($arg =~ /^--tool=/) {
$arg = substr($arg, 7);
setup_mergetool($arg);
next;
}
push @command, $arg;
}
return @command
}
# Sets up the git-difftool environment and execs 'git diff'.
sub main
{
setup_environment();
exec(generate_command());
}
main()
[-- Attachment #3: git-difftool-helper --]
[-- Type: application/octet-stream, Size: 5979 bytes --]
#!/bin/sh
#
# git-difftool-helper:
# invoked via 'git difftool' to view diffs using external diff viewers.
#
# Copyright (c) 2009 David Aguilar.
#
# You can use this script directly with the following settings:
# export GIT_PAGER=''
# export GIT_EXTERNAL_DIFF=git-difftool-helper
# git diff ...
# Should we prompt before viewing each file?
should_prompt () {
! test -n "$GIT_DIFFTOOL_NO_PROMPT"
}
# Should we keep the backup .orig file?
keep_backup_mode="$(git config --bool merge.keepBackup || echo true)"
keep_backup () {
test "$keep_backup_mode" = "true"
}
# This function manages the backup .orig file.
# A backup $MERGED.orig file is created if changes are detected.
cleanup_temp_files () {
if test -n "$MERGED"; then
if keep_backup && test "$MERGED" -nt "$BACKUP"; then
test -f "$BACKUP" && mv -- "$BACKUP" "$MERGED.orig"
else
rm -f -- "$BACKUP"
fi
fi
}
# This is called when users Ctrl-C out of git-difftool-helper.
sigint_handler () {
echo
cleanup_temp_files
exit 1
}
# This function prepares temporary files and launches the appropriate
# merge tool.
launch_merge_tool () {
# Merged is the filename as it appears in the work tree
# Local is the contents of a/filename
# Remote is the contents of b/filename
# Custom merge tool commands might use $BASE so we provide it
MERGED="$1"
LOCAL="$2"
REMOTE="$3"
BASE="$1"
ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
BACKUP="$MERGED.BACKUP.$ext"
# Create and ensure that we clean up $BACKUP
test -f "$MERGED" && cp -- "$MERGED" "$BACKUP"
trap sigint_handler SIGINT
# $LOCAL and $REMOTE are temporary files so prompt
# 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"
read ans
fi
# Run the appropriate merge tool command
case "$merge_tool" in
kdiff3)
basename=$(basename "$MERGED")
"$merge_tool_path" --auto \
--L1 "$basename (A)" \
--L2 "$basename (B)" \
-o "$MERGED" "$LOCAL" "$REMOTE" \
> /dev/null 2>&1
;;
tkdiff)
"$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
;;
meld|vimdiff)
"$merge_tool_path" "$LOCAL" "$REMOTE"
;;
gvimdiff)
"$merge_tool_path" -f "$LOCAL" "$REMOTE"
;;
xxdiff)
"$merge_tool_path" \
-X \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
--merged-file "$MERGED" \
"$LOCAL" "$REMOTE"
;;
opendiff)
"$merge_tool_path" "$LOCAL" "$REMOTE" \
-merge "$MERGED" | cat
;;
ecmerge)
"$merge_tool_path" "$LOCAL" "$REMOTE" \
--default --mode=merge2 --to="$MERGED"
;;
emerge)
"$merge_tool_path" -f emerge-files-command \
"$LOCAL" "$REMOTE" "$(basename "$MERGED")"
;;
*)
if test -n "$merge_tool_cmd"; then
( eval $merge_tool_cmd )
fi
;;
esac
cleanup_temp_files
}
# Verifies that mergetool.<tool>.cmd exists
valid_custom_tool() {
merge_tool_cmd="$(git config mergetool.$1.cmd)"
test -n "$merge_tool_cmd"
}
# Verifies that the chosen merge tool is properly setup.
# Built-in merge tools are always valid.
valid_tool() {
case "$1" in
kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
;; # happy
*)
if ! valid_custom_tool "$1"
then
return 1
fi
;;
esac
}
# Sets up the merge_tool_path variable.
# This handles the mergetool.<tool>.path configuration.
init_merge_tool_path() {
merge_tool_path=$(git config mergetool."$1".path)
if test -z "$merge_tool_path"; then
case "$1" in
emerge)
merge_tool_path=emacs
;;
*)
merge_tool_path="$1"
;;
esac
fi
}
# Allow the GIT_MERGE_TOOL variable to provide a default value
test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL"
# If not merge tool was specified then use the merge.tool
# configuration variable. If that's invalid then reset merge_tool.
if test -z "$merge_tool"; then
merge_tool=$(git config merge.tool)
if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then
echo >&2 "git config option merge.tool set to unknown tool: $merge_tool"
echo >&2 "Resetting to default..."
unset merge_tool
fi
fi
# Try to guess an appropriate merge tool if no tool has been set.
if test -z "$merge_tool"; then
# We have a $DISPLAY so try some common UNIX merge tools
if test -n "$DISPLAY"; then
merge_tool_candidates="kdiff3 tkdiff xxdiff meld gvimdiff"
# If gnome then prefer meld
if test -n "$GNOME_DESKTOP_SESSION_ID"; then
merge_tool_candidates="meld $merge_tool_candidates"
fi
# If KDE then prefer kdiff3
if test "$KDE_FULL_SESSION" = "true"; then
merge_tool_candidates="kdiff3 $merge_tool_candidates"
fi
fi
# $EDITOR is emacs so add emerge as a candidate
if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then
merge_tool_candidates="$merge_tool_candidates emerge"
fi
# $EDITOR is vim so add vimdiff as a candidate
if echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
merge_tool_candidates="$merge_tool_candidates vimdiff"
fi
merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
echo "merge tool candidates: $merge_tool_candidates"
# Loop over each candidate and stop when a valid merge tool is found.
for i in $merge_tool_candidates
do
init_merge_tool_path $i
if type "$merge_tool_path" > /dev/null 2>&1; then
merge_tool=$i
break
fi
done
if test -z "$merge_tool" ; then
echo "No known merge resolution program available."
exit 1
fi
else
# A merge tool has been set, so verify that it's valid.
if ! valid_tool "$merge_tool"; then
echo >&2 "Unknown merge tool $merge_tool"
exit 1
fi
init_merge_tool_path "$merge_tool"
if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then
echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
exit 1
fi
fi
# Launch the merge tool helper on each path passed to us by 'git diff'
while test $# -gt 6
do
launch_merge_tool "$1" "$2" "$5"
shift 7
done
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-02 17:39 ` git-difftool David Aguilar
@ 2009-01-15 22:26 ` Markus Heidelberg
2009-01-16 5:05 ` git-difftool David Aguilar
0 siblings, 1 reply; 16+ messages in thread
From: Markus Heidelberg @ 2009-01-15 22:26 UTC (permalink / raw)
To: David Aguilar; +Cc: Matthieu Moy, git
David Aguilar, 02.01.2009:
> I now have a git-difftool wrapper script that basically just sets up
> the environment for git-difftool-helper. git-difftool-helper does all
> of the merge tool configuration stuff ala
> http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html (it
> uses the same git config variables and thus works with existing custom
> commands). If you drop them both into the same directory it should
> work as-is (it munges $PATH).
>
> It's not a two-liner (they do all that git config stuff and handle
> more than just vimdiff) but it does use GIT_EXTERNAL_DIFF now, which
> makes the script infinitely more useful. This is much nicer now since
> you can pass any 'git diff' options to git-difftool and it'll handle
> it correctly.
>
> The usage is simpler now too:
>
> usage: git difftool [--no-prompt] [--tool=tool] ["git diff" options]
Now isn't this something for contrib, David?
Markus
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-15 22:26 ` git-difftool Markus Heidelberg
@ 2009-01-16 5:05 ` David Aguilar
0 siblings, 0 replies; 16+ messages in thread
From: David Aguilar @ 2009-01-16 5:05 UTC (permalink / raw)
To: markus.heidelberg; +Cc: Matthieu Moy, git
On Thu, Jan 15, 2009 at 2:26 PM, Markus Heidelberg
<markus.heidelberg@web.de> wrote:
> David Aguilar, 02.01.2009:
>> I now have a git-difftool wrapper script that basically just sets up
>> the environment for git-difftool-helper. git-difftool-helper does all
>> of the merge tool configuration stuff ala
>> http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html (it
>> uses the same git config variables and thus works with existing custom
>> commands). If you drop them both into the same directory it should
>> work as-is (it munges $PATH).
>>
>> It's not a two-liner (they do all that git config stuff and handle
>> more than just vimdiff) but it does use GIT_EXTERNAL_DIFF now, which
>> makes the script infinitely more useful. This is much nicer now since
>> you can pass any 'git diff' options to git-difftool and it'll handle
>> it correctly.
>>
>> The usage is simpler now too:
>>
>> usage: git difftool [--no-prompt] [--tool=tool] ["git diff" options]
>
> Now isn't this something for contrib, David?
>
> Markus
>
>
It sure is.
BTW the script worked beautifully on *nix.
I later decided to give it a try on Windows and of course it didn't
work right the first time. Once I added a check to use "git.exe"
instead of "git" then it started working again. I'll prepare some
documentation and post a patch later tonight.
Thanks for reminding me,
--
David
(p.s. Markus: sorry for the double-email -- I forgot to cc: the list)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-02 1:59 ` git-difftool Ping Yin
@ 2009-01-17 3:47 ` enso
2009-01-17 4:41 ` git-difftool David Aguilar
2009-01-17 14:17 ` git-difftool Ping Yin
0 siblings, 2 replies; 16+ messages in thread
From: enso @ 2009-01-17 3:47 UTC (permalink / raw)
To: git
Ping Yin wrote:
>
> Thanks. With GIT_PAGER="" it works now.
>
Personally, I didn't like having to screw around with environment variables
directly to get vimdiff to work. So I did the following:
1) Made a simple diff script gitvimdiff.sh:
#!/bin/env sh
vimdiff "$2" "$5"
2) git config --global diff.external ~/path/to/gitvimdiff.sh
3) git config --global pager.diff ""
Now when I run git-diff it uses vimdiff (hooray) and automatically turns the
pager off for me! Now only if I could get meld to work under cygwin.
--
View this message in context: http://n2.nabble.com/git-difftool-tp1814817p2171934.html
Sent from the git mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-17 3:47 ` git-difftool enso
@ 2009-01-17 4:41 ` David Aguilar
2009-01-17 14:17 ` git-difftool Ping Yin
1 sibling, 0 replies; 16+ messages in thread
From: David Aguilar @ 2009-01-17 4:41 UTC (permalink / raw)
To: enso; +Cc: git
On Fri, Jan 16, 2009 at 7:47 PM, enso <a.calhoon@gmail.com> wrote:
> Ping Yin wrote:
>>
>> Thanks. With GIT_PAGER="" it works now.
>>
>
> Personally, I didn't like having to screw around with environment variables
> directly to get vimdiff to work. So I did the following:
>
> 1) Made a simple diff script gitvimdiff.sh:
>
> #!/bin/env sh
> vimdiff "$2" "$5"
>
> 2) git config --global diff.external ~/path/to/gitvimdiff.sh
> 3) git config --global pager.diff ""
>
> Now when I run git-diff it uses vimdiff (hooray) and automatically turns the
> pager off for me! Now only if I could get meld to work under cygwin.
> --
Hello sir
It sounds like you were looking for exactly the patch I sent last night =)
http://article.gmane.org/gmane.comp.version-control.git/105925
With 'git difftool' you just do it once:
git config --global merge.tool vimdiff
git difftool [diff options]
The nice thing is that it supports the same configuration variables as
'git mergetool', so if you've already set things up to work correctly
with mergetool then you're already setup for difftool.
Meld.. I can't say I've used it on windows.
I have successfully used kdiff3 with msysgit, though. I just
downloaded it and copied it to /bin.
difftool supports meld, though, so if you get a build of meld that
works then you should in theory be able to use it just by setting
merge.tool to meld.
--
David
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: git-difftool
2009-01-17 3:47 ` git-difftool enso
2009-01-17 4:41 ` git-difftool David Aguilar
@ 2009-01-17 14:17 ` Ping Yin
1 sibling, 0 replies; 16+ messages in thread
From: Ping Yin @ 2009-01-17 14:17 UTC (permalink / raw)
To: enso; +Cc: git
On Sat, Jan 17, 2009 at 11:47 AM, enso <a.calhoon@gmail.com> wrote:
>
>
>
> Ping Yin wrote:
>>
>> Thanks. With GIT_PAGER="" it works now.
>>
>
> Personally, I didn't like having to screw around with environment variables
> directly to get vimdiff to work. So I did the following:
>
> 1) Made a simple diff script gitvimdiff.sh:
>
> #!/bin/env sh
> vimdiff "$2" "$5"
>
> 2) git config --global diff.external ~/path/to/gitvimdiff.sh
> 3) git config --global pager.diff ""
>
I am not aware of these configurations, thanks.
What i current do is to use an alias to use vimdiff for diff
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-01-17 14:18 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-26 1:30 git-difftool David Aguilar
2008-12-31 16:04 ` git-difftool Matthieu Moy
2008-12-31 20:11 ` git-difftool David Aguilar
2008-12-31 21:20 ` git-difftool Boyd Stephen Smith Jr.
2009-01-01 17:58 ` git-difftool Matthieu Moy
2009-01-02 0:13 ` git-difftool Markus Heidelberg
2009-01-02 16:10 ` git-difftool Matthieu Moy
2009-01-02 17:39 ` git-difftool David Aguilar
2009-01-15 22:26 ` git-difftool Markus Heidelberg
2009-01-16 5:05 ` git-difftool David Aguilar
2009-01-01 7:38 ` git-difftool Ping Yin
2009-01-02 0:04 ` git-difftool Markus Heidelberg
2009-01-02 1:59 ` git-difftool Ping Yin
2009-01-17 3:47 ` git-difftool enso
2009-01-17 4:41 ` git-difftool David Aguilar
2009-01-17 14:17 ` git-difftool Ping Yin
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).