All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>,
	Tanguy Ortolo <tanguy+debian@ortolo.eu>,
	Charles Bailey <charles@hashpling.org>,
	Sebastian Schuberth <sschuberth@gmail.com>
Subject: [PATCH v2 4/4] mergetools/meld: Use '--output' when available
Date: Fri, 19 Aug 2011 02:14:45 -0700	[thread overview]
Message-ID: <20110819091444.GB18054@gmail.com> (raw)
In-Reply-To: <1313652227-48545-5-git-send-email-davvid@gmail.com>

meld 1.5.0 and newer allow the output file to be specified
when merging multiple files.  Check whether the meld command
supports '--output' and use it when available.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 mergetools/meld |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

Changes since v1 with help from Jonathan Nieder:

Use $LOCAL $BASE REMOTE when calling meld.
Avoid shell portability issues by using the return status.
of --output instead of parsing --version.

diff --git a/mergetools/meld b/mergetools/meld
index 73d70ae..eaa115c 100644
--- a/mergetools/meld
+++ b/mergetools/meld
@@ -3,7 +3,30 @@ diff_cmd () {
 }
 
 merge_cmd () {
+	if test -z "${meld_has_output_option:+set}"
+	then
+		check_meld_for_output_version
+	fi
 	touch "$BACKUP"
-	"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
+	if test "$meld_has_output_option" = true
+	then
+		"$merge_tool_path" --output "$MERGED" \
+			"$LOCAL" "$BASE" "$REMOTE"
+	else
+		"$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
+	fi
 	check_unchanged
 }
+
+# Check whether 'meld --output <file>' is supported
+check_meld_for_output_version () {
+	meld_path="$(git config mergetool.meld.path)"
+	meld_path="${meld_path:-meld}"
+
+	if "$meld_path" --output /dev/null --help >/dev/null 2>&1
+	then
+		meld_has_output_option=true
+	else
+		meld_has_output_option=false
+	fi
+}
-- 
1.7.6.553.g1899

  parent reply	other threads:[~2011-08-19  9:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18  7:23 [PATCH 0/4] Refactor git-mergetool--lib.sh David Aguilar
2011-08-18  7:23 ` [PATCH 1/4] difftool--helper: Make style consistent with git David Aguilar
2011-08-18  7:49   ` Sebastian Schuberth
2011-08-18  9:08     ` David Aguilar
2011-08-18 17:31       ` Junio C Hamano
2011-08-18  7:23 ` [PATCH 2/4] mergetool--lib: " David Aguilar
2011-08-18  7:23 ` [PATCH 3/4] mergetool--lib: Refactor tools into separate files David Aguilar
2011-10-09  9:17   ` [PATCH da/difftool-mergtool-refactor] Makefile: fix permissions of mergetools/ checked out with permissive umask Jonathan Nieder
2011-10-09 11:43     ` Jonathan Nieder
2011-10-09 18:26       ` David Aguilar
2011-10-09 21:47         ` Jonathan Nieder
2011-10-11  0:00         ` Junio C Hamano
2011-08-18  7:23 ` [PATCH 4/4] mergetools/meld: Use '--output' when available David Aguilar
2011-08-18  8:13   ` Jonathan Nieder
2011-08-18  9:24     ` David Aguilar
2011-08-19  9:14   ` David Aguilar [this message]
2011-08-19 22:58     ` [PATCH v2 " Junio C Hamano
2011-08-18  7:57 ` [PATCH 0/4] Refactor git-mergetool--lib.sh Sebastian Schuberth

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=20110819091444.GB18054@gmail.com \
    --to=davvid@gmail.com \
    --cc=charles@hashpling.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=sschuberth@gmail.com \
    --cc=tanguy+debian@ortolo.eu \
    /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.