# how to create v2 patch

10 messages from 2007-12-01 to 2007-12-07. Participants: Tilman Schmidt, Pascal Obry, Mike Hommey, Jakub Narebski, Björn Steinbrink, Jan Hudec, Andreas Ericsson, Wincent Colaiuta.
Thread: https://gitlist.dev/t/11077

## Tilman Schmidt, 2007-12-01 12:41

Subject: how to create v2 patch
Message-ID: <47515693.9070405@imap.cc>
URL: https://gitlist.dev/e/47515693.9070405%40imap.cc

```
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, 2007-12-01 13:17

Subject: Re: how to create v2 patch
Message-ID: <47515EF3.8010507@obry.net>
URL: https://gitlist.dev/e/47515EF3.8010507%40obry.net
In-Reply-To: <47515693.9070405@imap.cc>

```
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.

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, 2007-12-01 13:43

Subject: Re: how to create v2 patch
Message-ID: <20071201134321.GA10997@glandium.org>
URL: https://gitlist.dev/e/20071201134321.GA10997%40glandium.org
In-Reply-To: <47515EF3.8010507@obry.net>

```
On Sat, Dec 01, 2007 at 02:17:39PM +0100, Pascal Obry wrote:
> 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

```

## Jakub Narebski, 2007-12-01 14:02

Subject: Re: how to create v2 patch
Message-ID: <m3r6i6wm1g.fsf@roke.D-201>
URL: https://gitlist.dev/e/m3r6i6wm1g.fsf%40roke.D-201
In-Reply-To: <47515693.9070405@imap.cc>

```
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).

-- 
Jakub Narebski
Poland

```

## Björn Steinbrink, 2007-12-01 14:14

Subject: Re: how to create v2 patch
Message-ID: <20071201141410.GA4430@atjola.homenet>
URL: https://gitlist.dev/e/20071201141410.GA4430%40atjola.homenet
In-Reply-To: <m3r6i6wm1g.fsf@roke.D-201>

```
On 2007.12.01 06:02:23 -0800, Jakub Narebski wrote:
> 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

```

## Tilman Schmidt, 2007-12-06 20:04

Subject: Re: how to create v2 patch
Message-ID: <475855D6.201@imap.cc>
URL: https://gitlist.dev/e/475855D6.201%40imap.cc
In-Reply-To: <20071201134321.GA10997@glandium.org>

```
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?

Thx
T.

-- 
Tilman Schmidt                          E-Mail: tilman@imap.cc
Bonn, Germany
Yes, I have searched Google!


```

## Jan Hudec, 2007-12-06 20:44

Subject: Re: how to create v2 patch
Message-ID: <20071206204405.GA4216@efreet.light.src>
URL: https://gitlist.dev/e/20071206204405.GA4216%40efreet.light.src
In-Reply-To: <475855D6.201@imap.cc>

```
On Thu, Dec 06, 2007 at 21:04:38 +0100, Tilman Schmidt wrote:
> 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, 2007-12-06 21:38

Subject: Re: how to create v2 patch
Message-ID: <47586BC6.2020100@obry.net>
URL: https://gitlist.dev/e/47586BC6.2020100%40obry.net
In-Reply-To: <475855D6.201@imap.cc>

```
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, 2007-12-06 22:03

Subject: Re: how to create v2 patch
Message-ID: <4758719F.1080408@op5.se>
URL: https://gitlist.dev/e/4758719F.1080408%40op5.se
In-Reply-To: <475855D6.201@imap.cc>

```
Tilman Schmidt wrote:
> 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, 2007-12-07 08:11

Subject: Re: how to create v2 patch
Message-ID: <71AAB890-A1BC-49AA-9695-9701356DB514@wincent.com>
URL: https://gitlist.dev/e/71AAB890-A1BC-49AA-9695-9701356DB514%40wincent.com
In-Reply-To: <475855D6.201@imap.cc>

```
El 6/12/2007, a las 21:04, Tilman Schmidt escribió:

> 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

```
