Skip to content

Commit

Permalink
contrib/difftool: Don't repeat merge tool candidates
Browse files Browse the repository at this point in the history
git difftool listed some candidates for mergetools twice, depending on
the environment.

This slightly changes the behavior when both KDE_FULL_SESSION and
GNOME_DESKTOP_SESSION_ID are set at the same time; in such a case
meld is used in favor of kdiff3 (the old code favored kdiff3 in such a
case), but it should not matter in practice.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Aguilar authored and Junio C Hamano committed Feb 1, 2009
1 parent 384770a commit 99ccaba
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions contrib/difftool/git-difftool-helper
Original file line number Diff line number Diff line change
Expand Up @@ -181,31 +181,24 @@ 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 kompare 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 or kompare
if test "$KDE_FULL_SESSION" = "true"; then
merge_tool_candidates="kdiff3 kompare $merge_tool_candidates"
# If gnome then prefer meld, otherwise, prefer kdiff3 or kompare
if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
merge_tool_candidates="meld kdiff3 kompare tkdiff xxdiff gvimdiff"
else
merge_tool_candidates="kdiff3 kompare tkdiff xxdiff meld gvimdiff"
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"
# $EDITOR is emacs so add emerge as a candidate
merge_tool_candidates="$merge_tool_candidates emerge opendiff vimdiff"
elif echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then
# $EDITOR is vim so add vimdiff as a candidate
merge_tool_candidates="$merge_tool_candidates vimdiff opendiff emerge"
else
merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff"
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.
Expand Down

0 comments on commit 99ccaba

Please sign in to comment.