* Interesting git-format-patch bug
@ 2012-11-26 21:33 Olsen, Alan R
2012-11-26 22:56 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Olsen, Alan R @ 2012-11-26 21:33 UTC (permalink / raw)
To: git@vger.kernel.org; +Cc: Olsen, Alan R
I found an interesting bug in git-format-patch.
Say you have a branch A. You create branch B and add a patch to it. You then merge that patch into branch A. After the merge, some other process (we will call it 'gerrit') uses annotate and changes the comment on the patch that exists on branch B.
Now someone runs git-format-patch for the last n patches on branch A. You should just get the original patch that was merged over to branch A. What you get is the patch that was merged to branch A *and* the patch with the modified commit comment on branch B. (Double the patches, double the clean-up...)
This is should be one of those rare corner case "don't do that" occurrences. Unfortunately it does happen once in a while on our branches and it screws up some of the automated processes we rely on.
Is there a way around that (other than "don't") or can this be fixed?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interesting git-format-patch bug
2012-11-26 21:33 Interesting git-format-patch bug Olsen, Alan R
@ 2012-11-26 22:56 ` Junio C Hamano
2012-11-27 4:15 ` Perry Hutchison
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-11-26 22:56 UTC (permalink / raw)
To: Olsen, Alan R; +Cc: git@vger.kernel.org
"Olsen, Alan R" <alan.r.olsen@intel.com> writes:
> I found an interesting bug in git-format-patch.
>
> Say you have a branch A. You create branch B and add a patch to
> it. You then merge that patch into branch A. After the merge, some
> other process (we will call it 'gerrit') uses annotate and changes
> the comment on the patch that exists on branch B.
>
> Now someone runs git-format-patch for the last n patches on branch
> A. You should just get the original patch that was merged over to
> branch A. What you get is the patch that was merged to branch A
> *and* the patch with the modified commit comment on branch
> B. (Double the patches, double the clean-up...)
As you literally have patches that do essentially the same or
similar things on two branches that was merged, you cannot expect to
export each individual commit into a patch and not have conflicts
among them. So I do not think there is no answer than "don't do
that".
I think you could make your "some other process" that rewrites
commits to cull the duplicates out of the format-patch output,
though. Each output file identifies what commit object the patch
came from, and your "some other process" that rewrote the commits
ought to know which commit updated which other commit did, which is
the piece of information needed to remove duplicates that format-patch
does not have.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interesting git-format-patch bug
2012-11-26 22:56 ` Junio C Hamano
@ 2012-11-27 4:15 ` Perry Hutchison
2012-11-27 17:29 ` Junio C Hamano
2012-11-27 20:31 ` Olsen, Alan R
0 siblings, 2 replies; 5+ messages in thread
From: Perry Hutchison @ 2012-11-27 4:15 UTC (permalink / raw)
To: gitster; +Cc: git, alan.r.olsen
Junio C Hamano <gitster@pobox.com> wrote:
> "Olsen, Alan R" <alan.r.olsen@intel.com> writes:
> > I found an interesting bug in git-format-patch.
> >
> > Say you have a branch A. You create branch B and add a patch to
> > it. You then merge that patch into branch A. After the merge,
> > some other process (we will call it 'gerrit') uses annotate and
> > changes the comment on the patch that exists on branch B.
> >
> > Now someone runs git-format-patch for the last n patches on
> > branch A. You should just get the original patch that was
> > merged over to branch A. What you get is the patch that was
> > merged to branch A *and* the patch with the modified commit
> > comment on branch B. (Double the patches, double the
> > clean-up...)
>
> As you literally have patches that do essentially the same or
> similar things on two branches that was merged, you cannot
> expect to export each individual commit into a patch and not
> have conflicts among them. So I do not think there is no
> answer than "don't do that".
To me, this seems to miss Alan's point: only one patch was merged
to branch A, so git-format-patch applied to branch A should find
only one patch. It can be argued either way whether that one-patch
report should include the gerrit annotations, but surely the
application of gerrit on branch B, _after the merge to branch A
has already been performed_, should not cause an additional patch
to magically appear on branch A.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interesting git-format-patch bug
2012-11-27 4:15 ` Perry Hutchison
@ 2012-11-27 17:29 ` Junio C Hamano
2012-11-27 20:31 ` Olsen, Alan R
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2012-11-27 17:29 UTC (permalink / raw)
To: Perry Hutchison; +Cc: git, alan.r.olsen
perryh@pluto.rain.com (Perry Hutchison) writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> "Olsen, Alan R" <alan.r.olsen@intel.com> writes:
>> > I found an interesting bug in git-format-patch.
>> >
>> > Say you have a branch A. You create branch B and add a patch to
>> > it. You then merge that patch into branch A. After the merge,
>> > some other process (we will call it 'gerrit') uses annotate and
>> > changes the comment on the patch that exists on branch B.
>> >
>> > Now someone runs git-format-patch for the last n patches on
>> > branch A. You should just get the original patch that was
>> > merged over to branch A. What you get is the patch that was
>> > merged to branch A *and* the patch with the modified commit
>> > comment on branch B. (Double the patches, double the
>> > clean-up...)
>>
>> As you literally have patches that do essentially the same or
>> similar things on two branches that was merged, you cannot
>> expect to export each individual commit into a patch and not
>> have conflicts among them. So I do not think there is no
>> answer than "don't do that".
>
> To me, this seems to miss Alan's point: only one patch was merged
> to branch A,...
Are you sure about this part?
I thought Alan's description was that he originally had this
x-----A
\ \
B-----M (a)
and then "some other process" made it like so:
x-----A
|\ \
| B-----M
\ \
B'------M' (a)
and then you ask to linealize the last n patches starting from the
rewritten M'.
If that "some other process" instead created a history like this:
x-----A---\
|\ \ \
| B-----M \
\ \
B'----------M' (a)
then the redone-merge M' will not see the old B that was fixed later
to B' in the history, but then format-patch would not show B so we
wouldn't be having this discussion thread.
It is possible that "some other process" may (ab)use the parent
field to record the evolution of B, to create a topology like this:
x-----A---\
|\ \ \
| B-----M \
\ \ \
\-B'--------M' (a)
in which case M' has parent B' but B' has a (phoney) parent B.
So again, it all depends on what "some other process" does to the
history when it rewrites it, and if somebody wants to fiter cruft in
the resulting history when flattening it, the knowledge of what
"some other process" does need to help that process.
Which is what I already said, I guess ;-)
> so git-format-patch applied to branch A should find
> only one patch. It can be argued either way whether that one-patch
> report should include the gerrit annotations, but surely the
> application of gerrit on branch B, _after the merge to branch A
> has already been performed_, should not cause an additional patch
> to magically appear on branch A.
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: Interesting git-format-patch bug
2012-11-27 4:15 ` Perry Hutchison
2012-11-27 17:29 ` Junio C Hamano
@ 2012-11-27 20:31 ` Olsen, Alan R
1 sibling, 0 replies; 5+ messages in thread
From: Olsen, Alan R @ 2012-11-27 20:31 UTC (permalink / raw)
To: Perry Hutchison, gitster@pobox.com; +Cc: git@vger.kernel.org
[Sorry for the top posting. Outlook is crap.]
You are correct. I should only get one copy of the patch on branch A. Branch B was modified after the merge and git-format-patch includes the original patch from the merge and a duplicate copy with the changed comments. Note that this patch only has different comments. The body of the patch is exactly the same.
How gerrit mangles things is out of my control. I would prefer that they cherry-pick instead of merges. I have to live with the bad choices of both gerrit and developers in this case.
I guess I will have to diagram out a better example of what is happening here.
-----Original Message-----
From: Perry Hutchison [mailto:perryh@pluto.rain.com]
Sent: Monday, November 26, 2012 8:15 PM
To: gitster@pobox.com
Cc: git@vger.kernel.org; Olsen, Alan R
Subject: Re: Interesting git-format-patch bug
Junio C Hamano <gitster@pobox.com> wrote:
> "Olsen, Alan R" <alan.r.olsen@intel.com> writes:
> > I found an interesting bug in git-format-patch.
> >
> > Say you have a branch A. You create branch B and add a patch to it.
> > You then merge that patch into branch A. After the merge, some other
> > process (we will call it 'gerrit') uses annotate and changes the
> > comment on the patch that exists on branch B.
> >
> > Now someone runs git-format-patch for the last n patches on branch
> > A. You should just get the original patch that was merged over to
> > branch A. What you get is the patch that was merged to branch A
> > *and* the patch with the modified commit comment on branch B.
> > (Double the patches, double the
> > clean-up...)
>
> As you literally have patches that do essentially the same or similar
> things on two branches that was merged, you cannot expect to export
> each individual commit into a patch and not have conflicts among them.
> So I do not think there is no answer than "don't do that".
To me, this seems to miss Alan's point: only one patch was merged to branch A, so git-format-patch applied to branch A should find only one patch. It can be argued either way whether that one-patch report should include the gerrit annotations, but surely the application of gerrit on branch B, _after the merge to branch A has already been performed_, should not cause an additional patch to magically appear on branch A.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-27 20:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26 21:33 Interesting git-format-patch bug Olsen, Alan R
2012-11-26 22:56 ` Junio C Hamano
2012-11-27 4:15 ` Perry Hutchison
2012-11-27 17:29 ` Junio C Hamano
2012-11-27 20:31 ` Olsen, Alan R
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox