git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
To: git@vger.kernel.org
Subject: Feature request: be able to pass arguments to difftool command
Date: Tue, 28 Aug 2018 17:57:11 +0200	[thread overview]
Message-ID: <20180828175711.3a0aeacc@pc09.procura.nl> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 6956 bytes --]

In short, I want to be able to do

 $ git difftool 5c5a -v2

where -v2 is passed to the tool invoked in the end. I'll elaborate on
why ...

Background.

Some changes are not obvious to spot. One of the best examples I found
is this one:
https://github.com/hexchat/hexchat/commit/5c5aacd9da7d45dfc1644b87de9e2379a1102d6a

$ git show 5c5a
commit 5c5aacd9da7d45dfc1644b87de9e2379a1102d6a
Author: Patrick Griffis <tingping@tingping.se>
Date:   Wed Apr 4 19:21:53 2018 -0400

    Fix another bad translation

diff --git a/po/el.po b/po/el.po
index 7d47ee1e..e54d62c1 100644
--- a/po/el.po
+++ b/po/el.po
@@ -1072,7 +1072,7 @@ msgstr "%C22*%O$t%C22$1%O: %C18$2%O κατά συνέχεια %C24$4%O από %C

 #: src/common/textevents.h:13
 msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
-msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%Ο)."
+msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%O)."

 #: src/common/textevents.h:19
 msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"


I bet none of you is able to spot the change in that line, even if
colored. I had a similar problem completely unrelated to git, and I
wrote the "ccdiff" tool, to do horizontally colored diff. As mail (when
used without HTML, as it ought to be used) is not apt to coloring, I
added an option to show markers under the changed text. I then
integrated the tool as much as possible into git

 $ cpan App::ccdiff
 $ git config --global diff.tool ccdiff
 $ git config --global difftool.prompt false
 $ git config --global difftool.ccdiff.cmd 'ccdiff --utf-8 -u $LOCAL $REMOTE'
 $ git difftool 5c5a~..5c5a
 --- /tmp/CXbTje_el.po   Tue Aug 28 17:38:02 2018
 +++ /tmp/8jrR7d_el.po   Tue Aug 28 17:38:02 2018
 1075,1075c1075,1075

  #: src/common/textevents.h:13
  msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
 -msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%Ο)."
 +msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%O)."

  #: src/common/textevents.h:19
  msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"

 $ cat >~/bin/git-ccdiff <<EOC
 #!/bin/sh

 commit=$1
 shift
 if [ "$commit" = "" ]; then
     git difftool
 else
     git difftool $commit~1..$commit
     fi
 EOF
 $ chmod 755 ~/bin/git-ccdiff
 $ git ccdiff 5c5a
 --- /tmp/Cw7VDo_el.po   Tue Aug 28 17:41:08 2018
 +++ /tmp/yuTGro_el.po   Tue Aug 28 17:41:08 2018
 1075,1075c1075,1075

  #: src/common/textevents.h:13
  msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
 -msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%Ο)."
 +msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%O)."

  #: src/common/textevents.h:19
  msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"

So, with all parts in place, I want more info

 $ git ccdiff 5c5a -m

No change. When I add -m to the cmd in ~/.gitconfig, like

[difftool "ccdiff"]
	cmd = ccdiff --utf-8 -u -m $LOCAL $REMOTE

 $ git ccdiff 5c5a
 --- /tmp/fXkf4E_el.po   Tue Aug 28 17:44:12 2018
 +++ /tmp/P3mZ1E_el.po   Tue Aug 28 17:44:12 2018
 1075,1075c1075,1075

  #: src/common/textevents.h:13
  msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
 -msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%Ο)."
 -                                                                       ▼
 +msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%O)."
 +                                                                       ▲

  #: src/common/textevents.h:19
  msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"

Nice, but I still cannot pass it from the command line, and in this
specific case I also want -v2 or -v3

cmd = ccdiff --utf-8 -u -m -v2 $LOCAL $REMOTE:

--- /tmp/dp0E5T_el.po   Tue Aug 28 17:45:51 2018
+++ /tmp/za7m3T_el.po   Tue Aug 28 17:45:51 2018
1075,1075c1075,1075

  #: src/common/textevents.h:13
  msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
 -msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%↱Ο↰)."
 -                                                                        ▼
 - -- verbose : GREEK CAPITAL LETTER OMICRON
 +msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%↱O↰)."
 +                                                                        ▲
 + -- verbose : LATIN CAPITAL LETTER O

  #: src/common/textevents.h:19
  msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"

cmd = ccdiff --utf-8 -u -m -v3 $LOCAL $REMOTE
(a screenshot is added to show the colors)

--- /tmp/4gPKTd_el.po   Tue Aug 28 17:47:57 2018
+++ /tmp/IreaTe_el.po   Tue Aug 28 17:47:57 2018
1075,1075c1075,1075

  #: src/common/textevents.h:13
  msgid "%C22*%O$tCannot join %C22$1 %O(%C20You are banned%O)."
 -msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%↱Ο↰)."
 -                                                                        ▼
 - -- verbose : GREEK CAPITAL LETTER OMICRON (U+00039F)
 +msgstr "%C22*%O$tΑδυναμία εισαγωγής %C22$1 %O(%C20Είστε μπλοκαρισμένος%↱O↰)."
 +                                                                        ▲
 + -- verbose : LATIN CAPITAL LETTER O (U+00004F)

  #: src/common/textevents.h:19
  msgid "%C29*%O$tCapabilities acknowledged: %C29$2%O"


The only workaround I could come up with (for now) is both ugly and
fragile: I keep the extra arguments in an environment variable and add
those back to the commandline after the command started. Very easy to
break though.

$ cat ~/bin/git-ccdiff
#!/pro/bin/perl

use 5.18.3;
use warnings;

my $commit;

if (@ARGV) {
    $ARGV[0] =~ m/^-/ or $commit = shift;
    }

@ARGV and $ENV{CCDIFF_OPTIONS} = "@ARGV";
my @git = qw( git difftool );
defined $commit and push @git, "$commit~1..$commit";
system @git;


So, my wish would be to have an option, possibly using -- to pass
additional command line arguments to git difftool, so that

 $ git difftool $commit~1..$commit -- -m -v2

would pass the arguments after -- transparantly to ccdiff (in my case)


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.29   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

[-- Attachment #1.2: 20180828174959.png --]
[-- Type: image/png, Size: 54385 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

             reply	other threads:[~2018-08-28 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 15:57 H.Merijn Brand [this message]
2018-08-28 19:37 ` Feature request: be able to pass arguments to difftool command Junio C Hamano
2018-08-29  7:18   ` H.Merijn Brand
2018-09-16  6:28     ` David Aguilar
2018-09-17 16:44       ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180828175711.3a0aeacc@pc09.procura.nl \
    --to=h.m.brand@xs4all.nl \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).