git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* Regression in patch add?
@ 2018-04-15 12:21 mqudsi
  2018-04-15 13:59 ` Martin Ågren
  2018-04-16 10:00 ` Phillip Wood
  0 siblings, 2 replies; 4+ messages in thread
From: mqudsi @ 2018-04-15 12:21 UTC (permalink / raw)
  To: git, mqudsi

Hello all,

I'm currently running the latest version of git built from `master`, and
I'm running into what appears to be a regression in the behavior of the
piecewise `git add -p` when applying a manually edited chunk.

I first run `git add -p`, then manually edit a chunk (after hitting `s`
once, if it matters). The chunk originally contains the following:

```diff
# Manual hunk edit mode -- see bottom for a quick guide
@@ -20,7 +20,7 @@
 	"call dein#add('Shougo/dein.vim', {'rev': 'master'})

 	" Add or remove your plugins here:
-	" call dein#add('flazz/vim-colorschemes')
-	call dein#add('Haron-Prime/evening_vim')
+	call dein#add('flazz/vim-colorschemes')
+	call dein#add('danilo-augusto/vim-afterglow')

 	"core plugins that change the behavior of vim and how we use it globally
```

Under git 2.7.4, I can edit it to the following, which is accepted
without a problem:

```diff
# Manual hunk edit mode -- see bottom for a quick guide
@@ -20,7 +20,7 @@
	"call dein#add('Shougo/dein.vim', {'rev': 'master'})

	" Add or remove your plugins here:
-	" call dein#add('flazz/vim-colorschemes')
-	call dein#add('Haron-Prime/evening_vim')
+	call dein#add('flazz/vim-colorschemes')
+	call dein#add('Haron-Prime/evening_vim')

	"core plugins that change the behavior of vim and how we use it globally
```

All I did here was remove one `+` line and manually add another (which
is a variant of the second `-` line).

Under git 2.17.0.252.gfe0a9ea, the same piece is opened in $VISUAL for
editing (and if left unmodified applies OK), but when modified in the
to the same exact value, after exiting the editor I receive the
following error from git:

    error: patch fragment without header at line 15: @@ -25,7 +25,8 @@

I'm not sure what to make of this.

Thank you,

Mahmoud Al-Qudsi
NeoSmart Technologies



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression in patch add?
  2018-04-15 12:21 Regression in patch add? mqudsi
@ 2018-04-15 13:59 ` Martin Ågren
  2018-04-16 10:01   ` Phillip Wood
  2018-04-16 10:00 ` Phillip Wood
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Ågren @ 2018-04-15 13:59 UTC (permalink / raw)
  To: mqudsi; +Cc: Git Mailing List, Phillip Wood

Hi Mahmoud

On 15 April 2018 at 14:21,  <mqudsi@neosmart.net> wrote:
> I first run `git add -p`, then manually edit a chunk (after hitting `s`
> once, if it matters). The chunk originally contains the following:

[...]

> Under git 2.7.4, I can edit it to the following, which is accepted
> without a problem:
>
> ```diff
> # Manual hunk edit mode -- see bottom for a quick guide
> @@ -20,7 +20,7 @@
>         "call dein#add('Shougo/dein.vim', {'rev': 'master'})
>
>         " Add or remove your plugins here:
> -       " call dein#add('flazz/vim-colorschemes')
> -       call dein#add('Haron-Prime/evening_vim')
> +       call dein#add('flazz/vim-colorschemes')
> +       call dein#add('Haron-Prime/evening_vim')
>
>         "core plugins that change the behavior of vim and how we use it globally
> ```
>
> All I did here was remove one `+` line and manually add another (which
> is a variant of the second `-` line).

So the line is identical (sans s/^-/+/). Interesting.

> Under git 2.17.0.252.gfe0a9ea, the same piece is opened in $VISUAL for
> editing (and if left unmodified applies OK), but when modified in the
> to the same exact value, after exiting the editor I receive the
> following error from git:
>
>     error: patch fragment without header at line 15: @@ -25,7 +25,8 @@

I can't seem to reproduce this with some very simple testing. Are you
able to share your files? Or even better, derive a minimal reproduction
recipe?

What happens if you do not do a "remove this line, then add it again",
but instead turn that unchanged line into context? That is, you edit the
hunk into something like this (but without white-space damage):

...
-       " call dein#add('flazz/vim-colorschemes')
+       call dein#add('flazz/vim-colorschemes')
        call dein#add('Haron-Prime/evening_vim')
...

Adding Phillip to cc, since he was recently working in this area and
might have an idea.

Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression in patch add?
  2018-04-15 12:21 Regression in patch add? mqudsi
  2018-04-15 13:59 ` Martin Ågren
@ 2018-04-16 10:00 ` Phillip Wood
  1 sibling, 0 replies; 4+ messages in thread
From: Phillip Wood @ 2018-04-16 10:00 UTC (permalink / raw)
  To: mqudsi, git; +Cc: Martin Ågren

On 15/04/18 13:21, mqudsi wrote:
> 
> Hello all,
> 
> I'm currently running the latest version of git built from `master`, and
> I'm running into what appears to be a regression in the behavior of the
> piecewise `git add -p` when applying a manually edited chunk.
> 
> I first run `git add -p`, then manually edit a chunk (after hitting `s`
> once, if it matters).

Thanks for mentioning that, it can matter as the code that stitches
split hunks back together can't cope with edited hunks properly (though
the code that checks the hunk immediately after it's been edited doesn't
bother to try and stitch things back together).

> The chunk originally contains the following:
> 
> ```diff
> # Manual hunk edit mode -- see bottom for a quick guide
> @@ -20,7 +20,7 @@
>  	"call dein#add('Shougo/dein.vim', {'rev': 'master'})
> 
>  	" Add or remove your plugins here:
> -	" call dein#add('flazz/vim-colorschemes')
> -	call dein#add('Haron-Prime/evening_vim')
> +	call dein#add('flazz/vim-colorschemes')
> +	call dein#add('danilo-augusto/vim-afterglow')
> 
>  	"core plugins that change the behavior of vim and how we use it globally
> ```
> 
> Under git 2.7.4, I can edit it to the following, which is accepted
> without a problem:
> 
> ```diff
> # Manual hunk edit mode -- see bottom for a quick guide
> @@ -20,7 +20,7 @@
> 	"call dein#add('Shougo/dein.vim', {'rev': 'master'})
> 
> 	" Add or remove your plugins here:
> -	" call dein#add('flazz/vim-colorschemes')
> -	call dein#add('Haron-Prime/evening_vim')
> +	call dein#add('flazz/vim-colorschemes')
> +	call dein#add('Haron-Prime/evening_vim')
> 
> 	"core plugins that change the behavior of vim and how we use it globally
> ```
> 
> All I did here was remove one `+` line and manually add another (which
> is a variant of the second `-` line).
> 
> Under git 2.17.0.252.gfe0a9ea, the same piece is opened in $VISUAL for
> editing (and if left unmodified applies OK), but when modified in the
> to the same exact value, after exiting the editor I receive the
> following error from git:
> 
>     error: patch fragment without header at line 15: @@ -25,7 +25,8 @@

I'm not quite sure what that error message is telling us, I need to
spend some time understanding the code in apply.c that creates this
error message.

I assume that the header is coming from the next hunk which was created
when you split the original hunk. If you could post the original hunk
before it was split and the hunk starting at line 25 after it was split
that might help.

As Martin said if you could share the files or come up with a
reproducible example that would really help in figuring out what is
going wrong.

Thanks for reporting this

Phillip


> I'm not sure what to make of this.
> 
> Thank you,
> 
> Mahmoud Al-Qudsi
> NeoSmart Technologies
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression in patch add?
  2018-04-15 13:59 ` Martin Ågren
@ 2018-04-16 10:01   ` Phillip Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Phillip Wood @ 2018-04-16 10:01 UTC (permalink / raw)
  To: Martin Ågren, mqudsi; +Cc: Git Mailing List, Phillip Wood

On 15/04/18 14:59, Martin Ågren wrote:
> Hi Mahmoud
> 
> On 15 April 2018 at 14:21,  <mqudsi@neosmart.net> wrote:
>> I first run `git add -p`, then manually edit a chunk (after hitting `s`
>> once, if it matters). The chunk originally contains the following:
> 
> [...]
> 
>> Under git 2.7.4, I can edit it to the following, which is accepted
>> without a problem:
>>
>> ```diff
>> # Manual hunk edit mode -- see bottom for a quick guide
>> @@ -20,7 +20,7 @@
>>         "call dein#add('Shougo/dein.vim', {'rev': 'master'})
>>
>>         " Add or remove your plugins here:
>> -       " call dein#add('flazz/vim-colorschemes')
>> -       call dein#add('Haron-Prime/evening_vim')
>> +       call dein#add('flazz/vim-colorschemes')
>> +       call dein#add('Haron-Prime/evening_vim')
>>
>>         "core plugins that change the behavior of vim and how we use it globally
>> ```
>>
>> All I did here was remove one `+` line and manually add another (which
>> is a variant of the second `-` line).
> 
> So the line is identical (sans s/^-/+/). Interesting.
> 
>> Under git 2.17.0.252.gfe0a9ea, the same piece is opened in $VISUAL for
>> editing (and if left unmodified applies OK), but when modified in the
>> to the same exact value, after exiting the editor I receive the
>> following error from git:
>>
>>     error: patch fragment without header at line 15: @@ -25,7 +25,8 @@
> 
> I can't seem to reproduce this with some very simple testing. Are you
> able to share your files? Or even better, derive a minimal reproduction
> recipe?
> 
> What happens if you do not do a "remove this line, then add it again",
> but instead turn that unchanged line into context? That is, you edit the
> hunk into something like this (but without white-space damage):
> 
> ...
> -       " call dein#add('flazz/vim-colorschemes')
> +       call dein#add('flazz/vim-colorschemes')
>         call dein#add('Haron-Prime/evening_vim')
> ...

That's a good idea to try

> Adding Phillip to cc, since he was recently working in this area

Thanks for cc-ing me

> and might have an idea.

I wish I did!

Best Wishes

Phillip
> 
> Martin
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-15 12:21 Regression in patch add? mqudsi
2018-04-15 13:59 ` Martin Ågren
2018-04-16 10:01   ` Phillip Wood
2018-04-16 10:00 ` Phillip Wood

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox