From: Junio C Hamano <gitster@pobox.com>
To: John Keeping <john@keeping.me.uk>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] add--interactive: respect diff.algorithm
Date: Sun, 23 Jun 2013 12:19:05 -0700 [thread overview]
Message-ID: <7v8v20fxee.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130612184410.GB23890@serenity.lan> (John Keeping's message of "Wed, 12 Jun 2013 19:44:10 +0100")
John Keeping <john@keeping.me.uk> writes:
>> > +my $diff_algorithm = ($repo->config('diff.algorithm') or 'default');
>> > +
>> > my $use_readkey = 0;
>> > my $use_termcap = 0;
>> > my %term_escapes;
>> > @@ -731,6 +733,9 @@ sub run_git_apply {
>> > sub parse_diff {
>> > my ($path) = @_;
>> > my @diff_cmd = split(" ", $patch_mode_flavour{DIFF});
>> > + if ($diff_algorithm ne "default") {
>> > + push @diff_cmd, "--diff-algorithm=${diff_algorithm}";
>> > + }
This is not exactly sanitary for "stash -p", whose DIFF element is
defined like so:
'stash' => {
DIFF => 'diff-index -p HEAD',
and you will end up appending an option after a non-option argument,
It may happen to be accepted by the command line parser which is
overly lax, but we would want to tighten it in the longer term.
As a band-aid, we could do something like the attached patch, but
for the longer term, we might need to rethink the way the tweaking
of the command line is done by $patch_mode_revision.
-- >8 --
Subject: add -i: add extra options at the right place in "diff" command line
Appending "--diff-algorithm=histogram" at the end of canned command
line for various modes of "diff" is correct for most of them but not
for "stash" that has a non-option already wired in, like so:
'stash' => {
DIFF => 'diff-index -p HEAD',
Appending an extra option after non-option may happen to work due to
overly lax command line parser, but that is not something we should
rely on. Instead, splice in the extra argument immediately after a
'-p' option, which is an option to ask for textual diff output that
has to be in all variants.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git-add--interactive.perl | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 5310959..b50551a 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -730,11 +730,23 @@ sub run_git_apply {
return close $fh;
}
+# The command array must have a single "-p" to ask for output in the
+# patch form. Splice additional options immediately after it; we
+# should not be randomly appending them, as some of the canned command.
+# has non-option argument like HEAD already on it.
+
+sub splice_diff_options {
+ my $diff_cmd = shift;
+ @$diff_cmd = map {
+ ($_ eq '-p') ? ($_, @_) : $_;
+ } @$diff_cmd;
+}
+
sub parse_diff {
my ($path) = @_;
my @diff_cmd = split(" ", $patch_mode_flavour{DIFF});
if (defined $diff_algorithm) {
- push @diff_cmd, "--diff-algorithm=${diff_algorithm}";
+ splice_diff_options(\@diff_cmd, "--diff-algorithm=${diff_algorithm}");
}
if (defined $patch_mode_revision) {
push @diff_cmd, $patch_mode_revision;
next prev parent reply other threads:[~2013-06-23 19:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-10 14:28 Different diff strategies in add --interactive John Keeping
2013-06-10 19:28 ` Junio C Hamano
2013-06-10 21:11 ` Jeff King
2013-06-10 21:46 ` John Keeping
2013-06-10 21:56 ` Jeff King
2013-06-12 18:44 ` [PATCH] add--interactive: respect diff.algorithm John Keeping
2013-06-12 19:18 ` Jeff King
2013-06-23 19:19 ` Junio C Hamano [this message]
2013-06-23 19:50 ` John Keeping
2013-06-23 20:37 ` 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=7v8v20fxee.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
--cc=peff@peff.net \
/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).