From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Aguilar <davvid@gmail.com>,
Jeff Epler <jepler@unpythonic.net>,
git@vger.kernel.org, Sebastian Schuberth <sschuberth@gmail.com>,
Charles Bailey <charles@hashpling.org>
Subject: [PATCH] mergetools/meld: Use --help output to detect --output support
Date: Fri, 10 Feb 2012 15:57:55 -0600 [thread overview]
Message-ID: <20120210215755.GL19216@burratino> (raw)
In-Reply-To: <7vwr7unzs8.fsf@alter.siamese.dyndns.org>
In v1.7.7-rc0~3^2 (2011-08-19), git mergetool's "meld" support learned
to use the --output option when calling versions of meld that are
detected to support it (1.5.0 and newer, hopefully).
Alas, it misdetects old versions (before 1.1.5, 2006-06-11) of meld as
supporting the option, so on systems with such meld, instead of
getting a nice merge helper, the operator gets a dialog box with the
text "Wrong number of arguments (Got 5)". (Version 1.1.5 is when meld
switched to using optparse. One consequence of that change was that
errors in usage are detected and signalled through the exit status
even when --help was passed.)
Luckily there is a simpler check that is more reliable: the usage
string printed by "meld --help" reliably reflects whether --output is
supported in a given version. Use it.
Reported-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:
> When an older meld fails when given --output for real (not with the dry
> run current code tries with --help), can we sanely detect that particular
> failure?
Unfortunately it just pops up a GUI with a modal dialog box like this:
___________________________________
| |
| Wrong number of arguments (Got 5) |
| |
| [Quit] [OK] |
|___________________________________|
If I choose "Quit", the exit status is 0.
But how about this? "meld --help | grep -e --output" seems to detect
support for the option reliably. With 2>&1 on the upstream of the
pipe, this even seems futureproof. ;-)
mergetools/meld | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mergetools/meld b/mergetools/meld
index eaa115cc..cb672a55 100644
--- a/mergetools/meld
+++ b/mergetools/meld
@@ -23,7 +23,7 @@ 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
+ if "$meld_path" --help 2>&1 | grep -e --output >/dev/null
then
meld_has_output_option=true
else
--
1.7.9
next prev parent reply other threads:[~2012-02-10 21:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-09 19:17 A note on modern git plus ancient meld ("wrong number of arguments") Jeff Epler
2012-02-10 2:42 ` David Aguilar
2012-02-10 8:23 ` Jonathan Nieder
2012-02-10 11:29 ` Sebastian Schuberth
2012-02-10 17:59 ` Jonathan Nieder
2012-02-10 21:28 ` Junio C Hamano
2012-02-10 21:57 ` Jonathan Nieder [this message]
2012-02-10 22:23 ` [PATCH] mergetools/meld: Use --help output to detect --output support Jeff Epler
2012-02-10 22:30 ` Jeff Epler
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=20120210215755.GL19216@burratino \
--to=jrnieder@gmail.com \
--cc=charles@hashpling.org \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jepler@unpythonic.net \
--cc=sschuberth@gmail.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 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).