Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: [PATCH] git-add--interactive.perl: Permit word-based diff

From: Thomas Rast <hidden>
Date: 2016-06-15 22:57:47

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

Jeff King [off-list ref] writes:
On Sat, Jun 15, 2013 at 04:01:04PM +0200, Mark Abraham wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help