git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cherry-pick: Add an option to prepend a string to the commit message

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 12, 2010, 07:18 UTC
Message-ID
<20100612071850.GA2765@burratino>
In-Reply-To
<4C132C7E.5090606@gmail.com>
Bobby Powers wrote:
> On 06/11/2010 11:28 PM, Jeff King wrote:
Show 19 quoted lines
>> FWIW, we can already do this kind of stuff with:
>>
>>   GIT_EDITOR="sed -i 1i$prefix" git cherry-pick -e $ref
>>
>> or
>>
>>   git cherry-pick -n $ref&&
>>   sed -i 1i$prefix .git/MERGE_MSG
>>   GIT_EDITOR=true git commit
>>
>> I'll admit the first one is not very intuitive. But it is easy to script
>> around the second form. For one of my examples, I would probably do:
>>
>>   git cherry-pick -n $ref&&
>>   git log -1 --format='%s%n%ncontent between subject and body%n%b' |
>>   git commit -F -
>
> I like this; it clearly hadn't occurred to me.  I can just use this
> format instead.

Sorry to misunderstand. Maybe something like this could help. Patch applies on top of cc/cherry-pick-series.

-- %< --
Subject: Documentation: explain use of cherry-pick -n in scripts
Add an example to indicate how to munge a commit while cherry-picking it.

The formatting is ugly because I do not know how to ask asciidoc to use a multiline heading in a definition list.

Based-on-work-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index bcb4c75..4769ca5 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -113,6 +113,17 @@ git cherry-pick --ff ..next::
 	are in next but not HEAD to the current branch, creating a new
 	commit for each new change.
 
+------------
+git checkout maint &&
+git cherry-pick -n bugfix &&
+git add new_file.txt &&
+git show -s bugfix --format='%s%n%n%b%n%nAlso add a new file.' |
+git commit -F -
+------------
+
+	Apply a bugfix on top of the maint branch and tweak it before
+	creating a new commit to record it.
+
 Author
 ------
 Written by Junio C Hamano <gitster@pobox.com>
Previous: Bobby PowersNext: Jeff King
Message 6 of 9 in “cherry-pick: Add an option to prepend a string to the commit message”
  1. cherry-pick: Add an option to prepend a string to the commit messageBobby Powers, Jun 12, 2010
  2. Jonathan NiederJun 12, 2010
  3. Junio C HamanoJun 12, 2010
  4. Jeff KingJun 12, 2010
  5. Bobby PowersJun 12, 2010
  6. Jonathan NiederJun 12, 2010
  7. Jeff KingJun 12, 2010
  8. Junio C HamanoJun 14, 2010
  9. Junio C HamanoJun 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.