isaac.hazan
isaac.hazan

Reputation: 3874

Git: Add a patch to an existing patch series

Say I have a patch series that looks as follows:

0000-cover-letter.patch
0001-Patch1.patch
0002-Patch2.patch

Now I would like to add 0003-Patch3.patch to be part of that series.

I could do the following:

git format-patch HEAD~1 --start-number 3

However that won't work because the cover-letter patch will not be updated.

Is there a way to do one of the following, which kind of achieve the same goal:

P.S: Re-generating the entire series(HEAD~3) is not option here because when the first patches were generated I edited them with a description of the patch that would be erased if I re-generate from scratch.

Upvotes: 1

Views: 149

Answers (1)

Guildenstern
Guildenstern

Reputation: 3841

Your desire to manually add new patches to a series suggests to me that you should improve your patch series workflow.

Ideally, creating a new set of patches should be so streamlined that you won’t want to fiddle with more things than you need.

Storing the cover letter

The cover letter should be stored somewhere. Two options out of an infinity:

  • Store it as the first commit on your branch in an “empty” (no tree changes) commit
    • So it’s stored in the commit message
  • Store it in a git-notes(1) message somewhere (the first commit?)

Storing free-form comments

You can store comments on patches, i.e. text that will neither be part of the commit message nor the patch proper. They go between the --- separator and the beginning of the diff.

Say someone on a previous review asked you to do X on that commit (err, patch). So you want to note that like this:

---
Note: I was asked by Timothy to do X in <link>

You can do that by creating a note on that commit:

git notes edit

With a message like the above. Which will be stored as:

---
Notes:
    I was asked by Timothy to do X in <link>

Minimal changes to the output of git patch-format

It seems that you (ideally) want to limit your post-patch format invocation work to editing the subject and body of your cover letter. And if you store that somewhere then it’s mostly just a question of copy–paste.

Upvotes: 0

Related Questions