Re: git add -p breaks after split on change at the top of the file

2017-08-20 Thread Junio C Hamano
Jeff King writes: > So that's one question I'm puzzled by: why does it work without an edit, > but fail with one. As this is the part of the system I long time ago declared a "works only some of the time" hack, I do not recall the exact details, but a key phrase "DIRTY" in the old discussion thr

Re: git add -p breaks after split on change at the top of the file

2017-08-20 Thread Jeff King
On Thu, Aug 17, 2017 at 12:22:19PM -0700, Junio C Hamano wrote: > Jeff King writes: > > > Of course this is a pretty ridiculous input in the first place. In > > theory it _could_ be figured out, but overlapping hunks like this are > > always going to cause problems (in this case, context from th

Re: git add -p breaks after split on change at the top of the file

2017-08-17 Thread Junio C Hamano
Jeff King writes: > Of course this is a pretty ridiculous input in the first place. In > theory it _could_ be figured out, but overlapping hunks like this are > always going to cause problems (in this case, context from the second > hunk became a removal, and the second hunk no longer applies).

Re: git add -p breaks after split on change at the top of the file

2017-08-17 Thread Junio C Hamano
Jeff King writes: > [+cc Junio, as this gets deep into git-apply innards] I've written off --recount and --allow-overlap as ugly workaround that happens to work some of the time but cannot be trusted long time ago. IIRC, before the "(e)dit" thing was added to "add -p", we counted the line numbe

Re: git add -p breaks after split on change at the top of the file

2017-08-17 Thread Jeff King
On Thu, Aug 17, 2017 at 05:03:08AM -0400, Jeff King wrote: > But that does the opposite of what we want: it makes this case work when > --allow-overlap isn't specified. I think my first attempt is probably > closer to the right direction (but we'd want to have it kick in only > when --allow-overla

Re: git add -p breaks after split on change at the top of the file

2017-08-17 Thread Jeff King
On Thu, Aug 17, 2017 at 04:41:09AM -0400, Jeff King wrote: > diff --git a/apply.c b/apply.c > index 41ee63e1db..606db58218 100644 > --- a/apply.c > +++ b/apply.c > @@ -2966,8 +2966,9 @@ static int apply_one_fragment(struct apply_state *state, >* In other words, a hunk that is (frag->oldpos

Re: git add -p breaks after split on change at the top of the file

2017-08-17 Thread Jeff King
[+cc Junio, as this gets deep into git-apply innards] On Wed, Aug 16, 2017 at 10:25:04PM +0200, Simon Ruderich wrote: > $ git add -p > diff --git a/file b/file > index 587be6b..74a69a0 100644 > --- a/file > +++ b/file > @@ -1 +1,4 @@ > +a > +b > x > +c >

git add -p breaks after split on change at the top of the file

2017-08-16 Thread Simon Ruderich
Hello, The following session reproduces the issue with Git 2.14.1: $ git init test $ cd test $ echo x >file $ git add file $ git commit -m commit $ printf 'a\nb\nx\nc\n' >file $ git add -p diff --git a/file b/file index 587be6b..74a69a0 100644 --- a/file