From: David Aguilar <davvid@gmail.com>
To: gitster@pobox.com, charles@hashpling.org
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: [PATCH 03/10] Add a mergetool-lib scriptlet for holding common merge tool functions
Date: Wed, 1 Apr 2009 05:55:07 -0700 [thread overview]
Message-ID: <1238590514-41893-4-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <1238590514-41893-3-git-send-email-davvid@gmail.com>
git-mergetool-lib provides common merge tool functions.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
.gitignore | 1 +
Documentation/git-mergetool-lib.txt | 42 +++++++++++++++++++++++++++++++++++
Makefile | 1 +
command-list.txt | 1 +
git-mergetool-lib.sh | 41 ++++++++++++++++++++++++++++++++++
5 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 Documentation/git-mergetool-lib.txt
create mode 100644 git-mergetool-lib.sh
diff --git a/.gitignore b/.gitignore
index 966c886..75c154a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Documentation/git-mergetool-lib.txt b/Documentation/git-mergetool-lib.txt
new file mode 100644
index 0000000..a8d62f5
--- /dev/null
+++ b/Documentation/git-mergetool-lib.txt
@@ -0,0 +1,42 @@
+git-mergetool-lib(1)
+====================
+
+NAME
+----
+git-mergetool-lib - Common git merge tool shell scriptlets
+
+SYNOPSIS
+--------
+'. "$(git --exec-path)/git-mergetool-lib"'
+
+DESCRIPTION
+-----------
+
+This is not a command the end user would want to run. Ever.
+This documentation is meant for people who are studying the
+Porcelain-ish scripts and/or are writing new ones.
+
+The 'git-mergetool-lib' scriptlet is designed to be sourced (using
+`.`) by other shell scripts to set up functions for working
+with git merge tools.
+
+Before sourcing it, your script should set up a few variables;
+`TOOL_MODE` is used to define the operation mode for various
+functions. 'diff' and 'merge' are valid values.
+
+FUNCTIONS
+---------
+get_merge_tool_path::
+ returns the `merge_tool_path` for a `merge_tool`.
+
+Author
+------
+Written by David Aguilar <davvid@gmail.com>
+
+Documentation
+--------------
+Documentation by David Aguilar and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Makefile b/Makefile
index d77fd71..086f9e7 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/command-list.txt b/command-list.txt
index fb03a2e..922c815 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -69,6 +69,7 @@ git-merge-file plumbingmanipulators
git-merge-index plumbingmanipulators
git-merge-one-file purehelpers
git-mergetool ancillarymanipulators
+git-mergetool-lib purehelpers
git-merge-tree ancillaryinterrogators
git-mktag plumbingmanipulators
git-mktree plumbingmanipulators
diff --git a/git-mergetool-lib.sh b/git-mergetool-lib.sh
new file mode 100644
index 0000000..c307a5d
--- /dev/null
+++ b/git-mergetool-lib.sh
@@ -0,0 +1,41 @@
+# git-mergetool-lib is a library for common merge tool functions
+diff_mode() {
+ test $TOOL_MODE = "diff"
+}
+
+get_merge_tool_path () {
+ if test -z "$2"; then
+ case "$1" in
+ emerge)
+ path=emacs
+ ;;
+ *)
+ path="$1"
+ ;;
+ esac
+ fi
+ echo "$path"
+}
+
+valid_tool () {
+ case "$1" in
+ kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
+ if test "$1" = "kompare" && ! diff_mode; then
+ return 1
+ fi
+ ;; # happy
+ *)
+ if ! test -n "$(get_custom_cmd "$1")"; then
+ return 1
+ fi ;;
+ esac
+}
+
+get_custom_cmd () {
+ diff_mode &&
+ custom_cmd="$(git config difftool.$1.cmd)"
+ test -z "$custom_cmd" &&
+ custom_cmd="$(git config mergetool.$1.cmd)"
+ test -n "$custom_cmd" &&
+ echo "$custom_cmd"
+}
--
1.6.1.3
next prev parent reply other threads:[~2009-04-01 12:58 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-01 12:55 git-{diff,merge} refactor round 2 David Aguilar
2009-04-01 12:55 ` [PATCH 01/10] difftool: add support for a difftool.prompt config variable David Aguilar
2009-04-01 12:55 ` [PATCH 02/10] mergetool: use $( ... ) instead of `backticks` David Aguilar
2009-04-01 12:55 ` David Aguilar [this message]
2009-04-01 12:55 ` [PATCH 04/10] mergetool: use get_mergetool_path from git-mergetool-lib David Aguilar
2009-04-01 12:55 ` [PATCH 05/10] difftool: " David Aguilar
2009-04-01 12:55 ` [PATCH 06/10] mergetool: use valid_tool " David Aguilar
2009-04-01 12:55 ` [PATCH 07/10] difftool: " David Aguilar
2009-04-01 12:55 ` [PATCH 08/10] mergetool-lib: introduce run_mergetool David Aguilar
2009-04-01 12:55 ` [PATCH 09/10] difftool: use run_mergetool from git-mergetool-lib David Aguilar
2009-04-01 12:55 ` [PATCH 10/10] mergetool: " David Aguilar
2009-04-01 22:54 ` Markus Heidelberg
2009-04-02 20:02 ` Charles Bailey
2009-04-02 20:13 ` Markus Heidelberg
2009-04-02 20:16 ` Markus Heidelberg
2009-04-03 1:54 ` David Aguilar
2009-04-01 22:47 ` [PATCH 08/10] mergetool-lib: introduce run_mergetool Markus Heidelberg
2009-04-01 22:39 ` [PATCH 03/10] Add a mergetool-lib scriptlet for holding common merge tool functions Markus Heidelberg
2009-04-02 3:58 ` David Aguilar
2009-04-02 19:59 ` git-{diff,merge} refactor round 2 Charles Bailey
2009-04-05 2:58 ` Markus Heidelberg
2009-04-05 3:34 ` David Aguilar
2009-04-05 9:45 ` Junio C Hamano
2009-04-05 21:15 ` David Aguilar
2009-04-05 22:15 ` Markus Heidelberg
2009-04-06 0:33 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1238590514-41893-4-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=charles@hashpling.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.