threads / discuss / 11077

how to create v2 patch

Subject: how to create v2 patch

## tl;dr

10 messages between Dec 1, 2007 and Dec 7, 2007.

replies: 9people: 8as markdown or json

Tilman Schmidt· Dec 1, 2007, 12:41 UTC · lore

Let's say that following the scheme laid out in http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Individual%20Developer%20(Participant) I have produced a patch, submitted it to LKML, received a few comments, committed appropriate changes to my local git tree, and now want to submit a revised patch. How do I do that? If I just run git-format-patch again, it produces my original patch plus a second one containing my updates, but what I need is a single new patch replacing the first one.

Thanks, Tilman

-- 
Tilman Schmidt                          E-Mail: tilman@imap.cc
Bonn, Germany
Yes, I have searched Google!
Pascal Obry· Dec 1, 2007, 13:17 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

Tilman Schmidt a écrit :
Show 8 quoted lines
> Let's say that following the scheme laid out in
> http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Individual%20Developer%20(Participant)
> I have produced a patch, submitted it to LKML, received a few
> comments, committed appropriate changes to my local git tree,
> and now want to submit a revised patch. How do I do that?
> If I just run git-format-patch again, it produces my original
> patch plus a second one containing my updates, but what I need
> is a single new patch replacing the first one.

Can't you merge both of your changes in your local repository? I would do that with an interactive rebase.

Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Mike Hommey· Dec 1, 2007, 13:43 UTC · re: Pascal Obry · lore

Re: how to create v2 patch

On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
Show 12 quoted lines
> Tilman Schmidt a écrit :
> > Let's say that following the scheme laid out in
> > http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Individual%20Developer%20(Participant)
> > I have produced a patch, submitted it to LKML, received a few
> > comments, committed appropriate changes to my local git tree,
> > and now want to submit a revised patch. How do I do that?
> > If I just run git-format-patch again, it produces my original
> > patch plus a second one containing my updates, but what I need
> > is a single new patch replacing the first one.
> 
> Can't you merge both of your changes in your local repository? I would
> do that with an interactive rebase.
Or just git commit --amend when committing.
Mike
Tilman Schmidt· Dec 6, 2007, 20:04 UTC · re: Mike Hommey · lore

Re: how to create v2 patch

Am 01.12.2007 14:43 schrieb Mike Hommey:
Show 12 quoted lines
> On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
>> Tilman Schmidt a écrit :
>>> I have produced a patch, submitted it to LKML, received a few
>>> comments, committed appropriate changes to my local git tree,
>>> and now want to submit a revised patch. How do I do that?
>>> If I just run git-format-patch again, it produces my original
>>> patch plus a second one containing my updates, but what I need
>>> is a single new patch replacing the first one.
>> Can't you merge both of your changes in your local repository? I would
>> do that with an interactive rebase.
> 
> Or just git commit --amend when committing.

Hmm. But wouldn't each of these approaches lead to my original commit being removed from my git repository? And isn't removing commits that have already been published strongly discouraged?

Thx T.

-- 
Tilman Schmidt                          E-Mail: tilman@imap.cc
Bonn, Germany
Yes, I have searched Google!
Jan Hudec· Dec 6, 2007, 20:44 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

On Thu, Dec 06, 2007 at 21:04:38 +0100, Tilman Schmidt wrote:
Show 17 quoted lines
> Am 01.12.2007 14:43 schrieb Mike Hommey:
> > On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
> >> Tilman Schmidt a écrit :
> >>> I have produced a patch, submitted it to LKML, received a few
> >>> comments, committed appropriate changes to my local git tree,
> >>> and now want to submit a revised patch. How do I do that?
> >>> If I just run git-format-patch again, it produces my original
> >>> patch plus a second one containing my updates, but what I need
> >>> is a single new patch replacing the first one.
> >> Can't you merge both of your changes in your local repository? I would
> >> do that with an interactive rebase.
> > 
> > Or just git commit --amend when committing.
> 
> Hmm. But wouldn't each of these approaches lead to my original
> commit being removed from my git repository? And isn't removing
> commits that have already been published strongly discouraged?

Removing commits that you already published is strongly discouraged. But patch is not a commit. A v2 (short for 'second version') patch means a patch, that should be applied /instead/ of the previous. The previous patch -- and the commit it was generated from as well as any commit generated by applying it -- should indeed be replaced by the new version.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Pascal Obry· Dec 6, 2007, 21:38 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

Tilman Schmidt a écrit :
> Hmm. But wouldn't each of these approaches lead to my original
> commit being removed from my git repository? And isn't removing
> commits that have already been published strongly discouraged?

They won't be removed, just changed/merged... and that's what you were looking for or I did not understand your question! This is not bad practice as it is done on YOUR repository. Of course this should never be done on a pushed/published changeset.

Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Andreas Ericsson· Dec 6, 2007, 22:03 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

Tilman Schmidt wrote:
Show 17 quoted lines
> Am 01.12.2007 14:43 schrieb Mike Hommey:
>> On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
>>> Tilman Schmidt a écrit :
>>>> I have produced a patch, submitted it to LKML, received a few
>>>> comments, committed appropriate changes to my local git tree,
>>>> and now want to submit a revised patch. How do I do that?
>>>> If I just run git-format-patch again, it produces my original
>>>> patch plus a second one containing my updates, but what I need
>>>> is a single new patch replacing the first one.
>>> Can't you merge both of your changes in your local repository? I would
>>> do that with an interactive rebase.
>> Or just git commit --amend when committing.
> 
> Hmm. But wouldn't each of these approaches lead to my original
> commit being removed from my git repository? And isn't removing
> commits that have already been published strongly discouraged?
> 

The term "published" means different things for different projects. For the Linux kernel, "published" is when your commit ends up in a repository that Linus pulls from.

So long as you're getting suggestions to fix up your patch, it's safe to assume it hasn't been accepted into one of those repos, and you can safely --amend the offending commit(s).

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Wincent Colaiuta· Dec 7, 2007, 08:11 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

El 6/12/2007, a las 21:04, Tilman Schmidt escribió:
Show 17 quoted lines
> Am 01.12.2007 14:43 schrieb Mike Hommey:
>> On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
>>> Tilman Schmidt a écrit :
>>>> I have produced a patch, submitted it to LKML, received a few
>>>> comments, committed appropriate changes to my local git tree,
>>>> and now want to submit a revised patch. How do I do that?
>>>> If I just run git-format-patch again, it produces my original
>>>> patch plus a second one containing my updates, but what I need
>>>> is a single new patch replacing the first one.
>>> Can't you merge both of your changes in your local repository? I  
>>> would
>>> do that with an interactive rebase.
>>
>> Or just git commit --amend when committing.
>
> Hmm. But wouldn't each of these approaches lead to my original
> commit being removed from my git repository?
Not immediately, but eventually. Let's say you have a history like this:
A--B--C--D
And you amend commit D to become D':
A--B--C--D'
        \
         D

You effectively have two "branches" now, but one of them (the original D) is unreferenced and will eventually be garbage collected. In other words, your ongoing development will look like this:

A--B--C--D'-E--F--G
        \
         D

At this point the only thing which references commit D will be your reflog, and with default settings that means that the commit will hang around for at least 90 more days before being pruned during garbage collection.

> And isn't removing
> commits that have already been published strongly discouraged?

Yes, normally that statement is true (because someone else may have based work on top of "D" and if you delete "D" then you just pulled the rug out from under them). But as others have pointed out, posting a PATCH to a mailing list isn't the same thing as "publishing a commit", so I won't repeat what's already been explained.

If, however, you really had *published* the commit (ie. pushed it out to an accessible repository) then you'd want to use "git revert" rather than "git commit --amend".

A--B--C--D--D'--E--F

Reverting doesn't delete any commits at all; instead it introduces a new commit (D') which undoes the change introduced in D. So you're undoing the *effect* of D without actually "undoing" the fact that you committed and published it.

Cheers, Wincent

Jakub Narebski· Dec 1, 2007, 14:02 UTC · re: Tilman Schmidt · lore

Re: how to create v2 patch

Tilman Schmidt <tilman@imap.cc> writes:
Show 5 quoted lines
> Let's say that following the scheme laid out in
> "Everyday GIT ...", chapter "Individual Developer (Participant)".
> I have produced a patch, submitted it to LKML, received a few
> comments, committed appropriate changes to my local git tree,
> and now want to submit a revised patch. How do I do that?

If you have original commit and commit with corrections on top of it, do a squash rebase using "git rebase -i" (interactive), or do a squash merge.

In the future it would be better to just amend ("git commit --amend") original commit (or if you are using StGIT, "stg refresh" it).

-- 
Jakub Narebski
Poland
Björn Steinbrink· Dec 1, 2007, 14:14 UTC · re: Jakub Narebski · lore

Re: how to create v2 patch

On 2007.12.01 06:02:23 -0800, Jakub Narebski wrote:
Show 14 quoted lines
> Tilman Schmidt <tilman@imap.cc> writes:
> 
> > Let's say that following the scheme laid out in
> > "Everyday GIT ...", chapter "Individual Developer (Participant)".
> > I have produced a patch, submitted it to LKML, received a few
> > comments, committed appropriate changes to my local git tree,
> > and now want to submit a revised patch. How do I do that?
> 
> If you have original commit and commit with corrections on top of it,
> do a squash rebase using "git rebase -i" (interactive), or do a squash
> merge.
> 
> In the future it would be better to just amend ("git commit --amend")
> original commit (or if you are using StGIT, "stg refresh" it).

For completeness: To use "git commit --amend" for any but the latest commit, you use rebase -i, too. Just change the "pick" for the commit you want to amend to "edit". Rebasing will stop _after_ applying that commit and you can amend it.

Björn

← back to recent threads