threads / discuss / 13045

Creating a patch set with git-format-patch

Subject: Creating a patch set with git-format-patch

## tl;dr

4 messages between Apr 10, 2008 and Apr 10, 2008.

replies: 3people: 4as markdown or json

Ian Brown· Apr 10, 2008, 08:51 UTC · lore
Hello,
  I have a question regarding creating a patch set with git-format-patch:
I had downloaded a git repository of the Linux kernel.

I intend to make a change in two files: net/ipv4/route.c and include/net/dst.h and send a patch set of two patches for review. Now I want to create this patch set of two pathces correctly; First patch for net/ipv4/route.c and second for include/net/dst.h.

what should I do ?

Regards, Ian

Björn Steinbrink· Apr 10, 2008, 10:56 UTC · re: Ian Brown · lore

Re: Creating a patch set with git-format-patch

On 2008.04.10 11:51:59 +0300, Ian Brown wrote:
Show 11 quoted lines
> Hello,
>   I have a question regarding creating a patch set with git-format-patch:
> I had downloaded a git repository of the Linux kernel.
> 
> I intend to  make a change in two files: net/ipv4/route.c and
> include/net/dst.h and send a
> patch set of two patches for review.
> Now I want to create this  patch set of two pathces correctly;
> First patch for net/ipv4/route.c and second for include/net/dst.h.
> 
> what should I do ?

Just create a branch for you work, then start working and creating commits. In the end, you'll get one patch for each commit, so group your work in the commits just as you want it to appear in the patches.

Then, create the patches with: git format-patch <options> master

That will create patches for all commits that are in your branch, but not in master. Finally, you can use either git send-email or your favourite mbox-capable MUA to send the patches.

HTH Björn

Stephan Beyer· Apr 10, 2008, 11:55 UTC · re: Björn Steinbrink · lore

Re: Creating a patch set with git-format-patch

Hi,
> Just create a branch for you work, then start working and creating
> commits.
> [...]

I've got a further question on that "patch-based" workflow because the documentation always stops at "send the patch".

Case 1:
 Assume your patch series get accepted.
 What to do with your local changes branch, say "my-changes"?
 Keeping it would result in a lot of dead branches after a while.
 So, I guess "git branch -D my-changes" is the cleanest way to go,
 but I'm not sure.
Case 2:
 Assume your patch series is not accepted but some patches
 are discussed and need some further work.
 What to do?[1]
 I guess the right way is (after updating master) to rebase--interactive
 the my-changes branch to the master and "edit" every commit that
 need further changes. After the rebase with all changes has finished,
 format-patch and re-send the interesting patches 
 (or format-patch the whole my-changes branch down to master and re-send
  only the changed patches)...
Are my guesses "right" for the two cases? Comments?
Regards,
 Stephan
Footnotes:
  1. Yes, there is step (3) of "An ideal patch flow" in
     http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/SubmittingPatches
     but it does not suggest steps how to "polish" and "refine".
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Sean Estabrooks· Apr 10, 2008, 10:56 UTC · re: Ian Brown · lore

Re: Creating a patch set with git-format-patch

On Thu, 10 Apr 2008 11:51:59 +0300 "Ian Brown" <ianbrn@gmail.com> wrote:

Hi Ian,
Show 6 quoted lines
> I intend to  make a change in two files: net/ipv4/route.c and
> include/net/dst.h and send a patch set of two patches for review.
> Now I want to create this  patch set of two pathces correctly;
> First patch for net/ipv4/route.c and second for include/net/dst.h.
> 
> what should I do ?

The first step is to edit route.c and commit your change to Git with a complete description[1]. Then edit the dst.h file and commit that to Git as a separate change. Afterward you can use git format-patch to prepare these commits to be emailed:

$  git format-patch HEAD^^

This tells Git to create a text file in the current directory for each commit made since the reference you pass. You can then configure git send-email[2] to send these text files out, or send them manually with your regular email client. If you do send them manually, make sure to include the text file inline in your email, don't send it as an attachment. You will find a subject line inside the file you can cut-and-paste into place, and a few other headers that you'll need to delete.

HTH, Sean

[1] Remember that each commit log entry should be made as a one-line overview, followed by a blank line, followed by as much prose as it takes to fully explain the change.

[2] There is a small section about configuring git-send-email for use with gmail using msmtp here: http://git.or.cz/gitwiki/GitTips

← back to recent threads