Skip to contentSkip to conversation

difftool/mergetool: refactor commands to use git-mergetool--lib

PATCH In review David Aguilar 2 participants 2 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 14/14 difftool/mergetool: refactor commands to use git-mergetool--lib

This consolidates the common functionality from git-mergetool and git-difftool--helper into a single git-mergetool--lib scriptlet.

---

with git I learn a new portability trick everyday. thanks all.

 .gitignore                           |    1 +
 Documentation/git-mergetool--lib.txt |   56 +++++
 Makefile                             |    1 +
 git-difftool--helper.sh              |  186 +----------------
 git-mergetool--lib.sh                |  381 ++++++++++++++++++++++++++++++++++
 git-mergetool.sh                     |  224 ++-------------------
 6 files changed, 461 insertions(+), 388 deletions(-)
 create mode 100644 Documentation/git-mergetool--lib.txt
 create mode 100644 git-mergetool--lib.sh
.gitignore +1 -0
index a36da9d..757c7f0 100644
@@ -80,6 +80,7 @@ git-merge-recursive
 git-merge-resolve
 git-merge-subtree
 git-mergetool
+git-mergetool--lib
 git-mktag
 git-mktree
 git-name-rev
Documentation/git-mergetool--lib.txt new file +56 -0

56 lines not on this page · raw message

Makefile +1 -0
index a80055f..3e56274 100644
@@ -284,6 +284,7 @@ SCRIPT_SH += git-merge-octopus.sh
 SCRIPT_SH += git-merge-one-file.sh
 SCRIPT_SH += git-merge-resolve.sh
 SCRIPT_SH += git-mergetool.sh
+SCRIPT_SH += git-mergetool--lib.sh
 SCRIPT_SH += git-parse-remote.sh
 SCRIPT_SH += git-pull.sh
 SCRIPT_SH += git-quiltimport.sh
git-difftool--helper.sh +9 -177

210 lines not on this page · raw message

git-mergetool--lib.sh new file +381 -0

381 lines not on this page · raw message

git-mergetool.sh +13 -211

255 lines not on this page · raw message

Signature · 1 line
1.6.2.2.446.gfbdc
#1 lore raw

git-mergetool--lib.sh line 294

Quoted 10 lines · David Aguilar

This consolidates the common functionality from git-mergetool and git-difftool--helper into a single git-mergetool--lib scriptlet.

git-mergetool--lib.sh new file +7 -0
+guess_merge_tool () {
+	tools="ecmerge"
+	if merge_mode; then
+		tools="tortoisemerge"
+	else
+		tools="kompare"
+	fi

The first assignment of ecmerge seems a no-op.

Quoted 10 lines
git-mergetool--lib.sh new file +10 -0
+	if test -n "$DISPLAY"; then
+		if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
+			tools="meld opendiff kdiff3 tkdiff xxdiff $tools \
+				gvimdiff diffuse ecmerge"
+		else
+			tools="opendiff kdiff3 tkdiff xxdiff meld $tools \
+				gvimdiff diffuse ecmerge"
+		fi
+	fi
+	if echo "${VISUAL:-$EDITOR}" | grep emacs > /dev/null 2>&1; then

git-mergetool--lib.sh line 314

Quoted 10 lines
git-mergetool--lib.sh new file +10 -0
+		# $EDITOR is emacs so add emerge as a candidate
+		tools="$tools emerge vimdiff"
+	elif echo "${VISUAL:-$EDITOR}" | grep vim > /dev/null 2>&1; then
+		# $EDITOR is vim so add vimdiff as a candidate
+		tools="$tools vimdiff emerge"
+	else
+		tools="$tools emerge vimdiff"
+	fi
+	tools="$(echo "$tools" | sed -e 's/ 	*/ /g')"
+	echo >&2 "merge tool candidates: $tools"

Sorry, but I am not sure what this is doing. Replace a SP followed by zero or more HT with a single SP?

Ahh, you are removing the HT in the indentation part?

I'd rather see the above written like this if that is the case:

git-mergetool--lib.sh line 303

Quoted 8 lines
git-mergetool--lib.sh new file +8 -0
+	if test -n "$DISPLAY"; then
+		if test -n "$GNOME_DESKTOP_SESSION_ID" ; then
+			tools="meld opendiff kdiff3 tkdiff xxdiff $tools"
+		else
+			tools="opendiff kdiff3 tkdiff xxdiff meld $tools"
+		fi
+ 		tools="$tools gvimdiff diffuse ecmerge"
+	fi

then you can lose the "echo | sed", no?