Feature request: be able to pass arguments to difftool command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
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: 20180828174959.png
Description: PNG image

Attachment: pgp_Urb13Th9S.pgp
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux