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

[PATCH 2/2] git-cherry-pick.txt: make clearer when revision walking gets activated

From
Carlos Martín Nieto <cmn@elego.de>
Date
Jun 15, 2012, 14:33 UTC
Message-ID
<1339770796-542-2-git-send-email-cmn@elego.de>
In-Reply-To
<1339770796-542-1-git-send-email-cmn@elego.de>

When given a set of commits, cherry-pick will apply the changes for all of them. Specifying a simple range will also work as expected. This can cause the user to think that

    git cherry-pick A B..C

will apply A and then B..C. This is not what happens. Instead the revs are given to rev-list which will consider A and C as positive revs and B as a negative one. Add a note about this and add an example with this particular syntax, which has shown up on the list a few times.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
---
 Documentation/git-cherry-pick.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 06a0bfd..10abfbf 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -48,6 +48,7 @@ OPTIONS
 	Sets of commits can be passed but no traversal is done by
 	default, as if the '--no-walk' option was specified, see
 	linkgit:git-rev-list[1].
+	Note that specifying a range will activate revision walking.
 
 -e::
 --edit::
@@ -130,6 +131,15 @@ EXAMPLES
 	Apply the changes introduced by all commits that are ancestors
 	of master but not of HEAD to produce new commits.
 
+`git cherry-pick master next ^maint`::
+`git cherry-pick master maint..next`::
+
+	Apply the changes introduced by all commits that are ancestors
+	of master or next, but not maint or any of its ancestors. The
+	second spelling is often a misunderstanding of revision
+	walking works when trying to apply a range plus a particular
+	commit and included for completeness.
+
 `git cherry-pick master~4 master~2`::
 
 	Apply the changes introduced by the fifth and third last
-- 
1.7.10.2.520.g6a4a482
Previous: Carlos Martín NietoNext: Junio C Hamano
Message 6 of 11 in “[BUG] cherry-pick ignores some arguments”
  1. Yann DirsonJun 14, 2012
  2. Carlos Martín NietoJun 14, 2012
  3. Yann DirsonJun 15, 2012
  4. Carlos Martín NietoJun 15, 2012
  5. 1/2 Documentation: --no-walk is no-op if range is specifiedCarlos Martín Nieto, Jun 15, 2012
  6. 2/2 git-cherry-pick.txt: make clearer when revision walking gets activatedCarlos Martín Nieto, Jun 15, 2012
  7. Junio C HamanoJun 15, 2012
  8. Junio C HamanoJun 15, 2012
  9. Carlos Martín NietoJun 15, 2012
  10. Junio C HamanoJun 15, 2012
  11. Junio C HamanoJun 15, 2012

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.