From: David Aguilar <davvid@gmail.com>
To: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Feature request: be able to pass arguments to difftool command
Date: Sat, 15 Sep 2018 23:28:00 -0700 [thread overview]
Message-ID: <20180916062800.GA18517@gmail.com> (raw)
In-Reply-To: <20180829091838.2eee8a6a@pc09.procura.nl>
On Wed, Aug 29, 2018 at 09:18:38AM +0200, H.Merijn Brand wrote:
> On Tue, 28 Aug 2018 12:37:40 -0700, Junio C Hamano <gitster@pobox.com>
> wrote:
>
> > "H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> >
> > > 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)
> >
> > At the syntax level passing any option after "--" would be a no
> > starter, as I would imagine that "git difftool $revs -- $paths"
> > should still be supported.
> >
> > At the concept level, however, I can see why such a feature would be
> > useful. Perhaps
> >
> > $ git difftool --backend-option=-m --backend-option=-v2 HEAD
> > $ git mergetool --backend-option=--foo
>
> This would mean I can just pass remaining arguments, like this?
>
> --8<--- ~/bin/git-ccdiff
> #!/usr/bin/env perl
> use 5.18.3;
> use warnings;
>
> my $commit;
>
> @ARGV && $ARGV[0] !~ m/^-/ and $commit = shift;
>
> my @git = qw( git difftool );
> defined $commit and push @git, "$commit~1..$commit";
> system @git, @ARGV;
> -->8---
>
> > with appropriate way(s) [*1*] to make it easier to type (and
> > implement) would be an acceptable avenue to pursue, I wonder?
>
> I like it, as long as they are all separate options in the backend and
> not available in one single variable that needs to be split
>
> I can envision a configure variable like
>
> backends.options.separator = U+2063
>
> so the backend can safely split on that itself. But I also see this as
> overly complex en over-engineering
Personally, I think it'd be better to keep the tool simple.
While I do see the utility, it would be just as easy to configure a 2nd
and 3rd variant of the same difftool and use those as needed instead.
"git difftool -t ccdiff2" or "-t ccdiff3" is the simplest, and there's
nothing stopping the user from creating aliases to shorten it further.
We also already have, "git difftool -x / --extcmd"
for specifying a full-on external diff command.
> git -c difftool.ccdiff.opts=-v2 -c difftool.ccdiff.opts=-m difftool
For example, this seems simpler as:
git difftool -x 'ccdiff -v2 -m'
We already have two mechanisms for controlling the inner command that's
launched by difftool. IMO we don't need more.
My primary concerns with --backend-opts are as follows:
1. If we add a mechansim for passing -X/--backend-opts, then we
need to specify a new variable that users will need to be aware
of when creating custom commands. (sorry for stating the obvious)
2. All of the built-in commands would need to change to honor that
variable.
3. The documentation becomes more complex because someone that wants
to configure a bog-standard custom external tool now needs to
be aware of this extra external source of arguments.
#1 and #2 are primarily implementation concerns, but #3 suggests
to me that it's over-complicating things.
Furthermore, #2 is not really that simple.
What would the sciplet look like?
diff_cmd () {
"$merge_tool_path" $EXTRA_ARGS ...
}
That implies that we would need to shell quote stuff when
constructing $EXTRA_ARGS internally if we were to support multiple -X
arguments. That just made it a bit more complex.
IMO we should be working to simpliify, not make things more complex for
rare use cases. There's no reason the user can't just do:
V=2 git difftool
V=3 git difftool
... and let the inner script check for $V (or any other) variable.
While environment variables aren't great, this does seem like the right
place to use them.
Another option -- we already eval the configured command, so if the user
includes a variable ($ARGS) in their custom configuration then they can
specify extra flags today without needing to change the tool. ex:
[difftool "ccdiff"]
cmd = ccdiff $ARGS \"$LOCAL\" \"$REMOTE\"
ARGS='-v2 -m' git difftool HEAD~1..HEAD
Are these alternatives short and simple enough?
--
David
next prev parent reply other threads:[~2018-09-16 6:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-28 15:57 Feature request: be able to pass arguments to difftool command H.Merijn Brand
2018-08-28 19:37 ` Junio C Hamano
2018-08-29 7:18 ` H.Merijn Brand
2018-09-16 6:28 ` David Aguilar [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180916062800.GA18517@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=h.m.brand@xs4all.nl \
/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).