* Applying a patch with a diff header in its commit message
@ 2021-06-28 18:30 Pratyush Yadav
2021-06-28 23:44 ` Felipe Contreras
0 siblings, 1 reply; 5+ messages in thread
From: Pratyush Yadav @ 2021-06-28 18:30 UTC (permalink / raw)
To: git
Hi,
I have a patch at $DAYJOB that contains a diff header ("diff --git
a/...") in its commit message, and unfortunately it is not indented. So
naturally, git-am trips up and thinks it is the start of the main diff
and tries to apply the diff starting there. It does not apply and the
patch is rejected as being corrupt.
I know one option for me is to manually edit the patch and indent the
diff header. But I would like to avoid that if possible. Is there any
way to apply that patch as-is? Is it possible to tell git-am where to
start looking for the diff?
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Applying a patch with a diff header in its commit message
2021-06-28 18:30 Applying a patch with a diff header in its commit message Pratyush Yadav
@ 2021-06-28 23:44 ` Felipe Contreras
2021-07-06 8:17 ` Pratyush Yadav
0 siblings, 1 reply; 5+ messages in thread
From: Felipe Contreras @ 2021-06-28 23:44 UTC (permalink / raw)
To: Pratyush Yadav, git
Pratyush Yadav wrote:
> I have a patch at $DAYJOB that contains a diff header ("diff --git
> a/...") in its commit message, and unfortunately it is not indented. So
> naturally, git-am trips up and thinks it is the start of the main diff
> and tries to apply the diff starting there. It does not apply and the
> patch is rejected as being corrupt.
>
> I know one option for me is to manually edit the patch and indent the
> diff header. But I would like to avoid that if possible. Is there any
> way to apply that patch as-is? Is it possible to tell git-am where to
> start looking for the diff?
git apply?
--
Felipe Contreras
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Applying a patch with a diff header in its commit message
2021-06-28 23:44 ` Felipe Contreras
@ 2021-07-06 8:17 ` Pratyush Yadav
2021-07-06 14:37 ` Ævar Arnfjörð Bjarmason
2021-07-06 22:17 ` Felipe Contreras
0 siblings, 2 replies; 5+ messages in thread
From: Pratyush Yadav @ 2021-07-06 8:17 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
On 28/06/21 06:44PM, Felipe Contreras wrote:
> Pratyush Yadav wrote:
> > I have a patch at $DAYJOB that contains a diff header ("diff --git
> > a/...") in its commit message, and unfortunately it is not indented. So
> > naturally, git-am trips up and thinks it is the start of the main diff
> > and tries to apply the diff starting there. It does not apply and the
> > patch is rejected as being corrupt.
> >
> > I know one option for me is to manually edit the patch and indent the
> > diff header. But I would like to avoid that if possible. Is there any
> > way to apply that patch as-is? Is it possible to tell git-am where to
> > start looking for the diff?
>
> git apply?
Sure, that is an option. But then I would have to copy/paste the commit
message and add the author information manually. Is there any way to do
this automatically? What if I have 100 commits like this?
This is a valid Git commit. It would be nice if the Git email tooling
could handle it cleanly.
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Applying a patch with a diff header in its commit message
2021-07-06 8:17 ` Pratyush Yadav
@ 2021-07-06 14:37 ` Ævar Arnfjörð Bjarmason
2021-07-06 22:17 ` Felipe Contreras
1 sibling, 0 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-07-06 14:37 UTC (permalink / raw)
To: Pratyush Yadav; +Cc: Felipe Contreras, git
On Tue, Jul 06 2021, Pratyush Yadav wrote:
> On 28/06/21 06:44PM, Felipe Contreras wrote:
>> Pratyush Yadav wrote:
>> > I have a patch at $DAYJOB that contains a diff header ("diff --git
>> > a/...") in its commit message, and unfortunately it is not indented. So
>> > naturally, git-am trips up and thinks it is the start of the main diff
>> > and tries to apply the diff starting there. It does not apply and the
>> > patch is rejected as being corrupt.
>> >
>> > I know one option for me is to manually edit the patch and indent the
>> > diff header. But I would like to avoid that if possible. Is there any
>> > way to apply that patch as-is? Is it possible to tell git-am where to
>> > start looking for the diff?
>>
>> git apply?
>
> Sure, that is an option. But then I would have to copy/paste the commit
> message and add the author information manually. Is there any way to do
> this automatically? What if I have 100 commits like this?
>
> This is a valid Git commit. It would be nice if the Git email tooling
> could handle it cleanly.
I don't think there is, but it could be fixed.
I had this happen to me the other day and ended up reading the relevant
parsing code, I think if it were a bit smarter we could handle the
common case, i.e. when we find "diff --git" or whatever it is keep
looking and see if we find another one, or perhaps have a "looks like
I'm at the diffstat" heuristic where we'll prefer the "diff --git" that
follows a "---" line, if there' two of them (that's also going to be
ambiguous, but both of them are less likely to happen to the same
commit).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Applying a patch with a diff header in its commit message
2021-07-06 8:17 ` Pratyush Yadav
2021-07-06 14:37 ` Ævar Arnfjörð Bjarmason
@ 2021-07-06 22:17 ` Felipe Contreras
1 sibling, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2021-07-06 22:17 UTC (permalink / raw)
To: Pratyush Yadav, Felipe Contreras; +Cc: git
Pratyush Yadav wrote:
> On 28/06/21 06:44PM, Felipe Contreras wrote:
> > Pratyush Yadav wrote:
> > > I have a patch at $DAYJOB that contains a diff header ("diff --git
> > > a/...") in its commit message, and unfortunately it is not indented. So
> > > naturally, git-am trips up and thinks it is the start of the main diff
> > > and tries to apply the diff starting there. It does not apply and the
> > > patch is rejected as being corrupt.
> > >
> > > I know one option for me is to manually edit the patch and indent the
> > > diff header. But I would like to avoid that if possible. Is there any
> > > way to apply that patch as-is? Is it possible to tell git-am where to
> > > start looking for the diff?
> >
> > git apply?
>
> Sure, that is an option. But then I would have to copy/paste the commit
> message and add the author information manually. Is there any way to do
> this automatically? What if I have 100 commits like this?
Ahh, I misread your full question.
> This is a valid Git commit. It would be nice if the Git email tooling
> could handle it cleanly.
Yes it would, that's definitely a bug.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-06 22:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 18:30 Applying a patch with a diff header in its commit message Pratyush Yadav
2021-06-28 23:44 ` Felipe Contreras
2021-07-06 8:17 ` Pratyush Yadav
2021-07-06 14:37 ` Ævar Arnfjörð Bjarmason
2021-07-06 22:17 ` Felipe Contreras
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.