git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Rast <trast@inf.ethz.ch>
To: Jeff King <peff@peff.net>
Cc: Mark Abraham <mark.j.abraham@gmail.com>, <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH] git-add--interactive.perl: Permit word-based diff
Date: Tue, 18 Jun 2013 09:22:16 +0200	[thread overview]
Message-ID: <87k3lrzxw7.fsf@hexa.v.cablecom.net> (raw)
In-Reply-To: <20130618063144.GA6276@sigill.intra.peff.net> (Jeff King's message of "Tue, 18 Jun 2013 02:31:46 -0400")

[I don't seem to have received a copy of the original mail, so I can
only guess...]

Jeff King <peff@peff.net> writes:

> On Sat, Jun 15, 2013 at 04:01:04PM +0200, Mark Abraham wrote:
>
>> Controlled by new configuration option
>> "color.word-diff-in-interactive-add". There is no existing support for
>> "git add" to pass a command-line option like "--word-diff=color" to
>> git-add--interactive.perl, so a configuration option is the only
>> lightweight solution.
>> 
>> With this feature, the added or deleted form of a hunk can be empty,
>> so made some necessary checks for $_ being defined.
>
> Hmm. We can't apply a word-diff, so presumably your "permit" here is
> just for the display, replacing the colorized bits. And that looks like
> what your patch does.
>
> Note that the number of lines in your --word-diff=color hunk and the
> actual diff will not necessarily be the same.  What happens if I split a
> hunk with your patch?

If it's actually what you hint at, there's another problem: the word
diff might not even have the same number of hunks.  For example, a
long-standing bug (or feature, depending on POV) of word-diff is that it
does not take opportunities to completely drop hunks that did not make
any word-level changes.

Consider this:

  diff --git a/foo b/foo
  index 5eaddaa..089eeac 100644
  --- a/foo
  +++ b/foo
  @@ -1,2 +1,2 @@
  -foo bar                                                                                               
  -baz                                                                                                   
  +foo                                                                                                   
  +bar baz

In word-diff mode that's

  diff --git a/foo b/foo                                                                                 
  index 5eaddaa..089eeac 100644                                                                          
  --- a/foo                                                                                              
  +++ b/foo                                                                                              
  @@ -1,2 +1,2 @@                                                                                        
  foo                                                                                                    
  bar baz

Arguably word-diff should be fixed to drop the hunk.  But if 'add -p'
depends on exact hunk correspondence, it will break.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

  reply	other threads:[~2013-06-18  7:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMNuMARruu+1=kny=g5O1MoxCXuoT3BHdSEEPSqvyn2t2JsAYg@mail.gmail.com>
2013-06-18  6:31 ` [PATCH] git-add--interactive.perl: Permit word-based diff Jeff King
2013-06-18  7:22   ` Thomas Rast [this message]
2013-06-18 17:23     ` Jeff King
2013-06-18 21:12       ` Mark Abraham
2013-06-18 22:47         ` Jeff King

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=87k3lrzxw7.fsf@hexa.v.cablecom.net \
    --to=trast@inf.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mark.j.abraham@gmail.com \
    --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).