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

Re: [PATCH 5/8] revert: allow cherry-picking more than one commit

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 1, 2010, 08:35 UTC
Message-ID
<20100601083549.GA28377@progeny.tock>
In-Reply-To
<20100531194240.28729.9164.chriscool@tuxfamily.org>
Christian Couder wrote:
Show 6 quoted lines
> The following should be possible but does not work:
> 
> 	git cherry-pick -2 master
> 
> because "git rev-list --no-walk -2 master" only outputs
> one commit as "--no-walk" seems to take over "-2".
Are the semantics of --no-walk documented anywhere?

In the spirit of v1.6.4-rc1~3 (Make 'git show' more useful, 2009-07-13), we could make -n imply --do-walk.

This would change the meaning of git show -5 --all, so I am not too happy with it.

-- 8< --
Subject: DWIM 'git show -5' to 'git show --do-walk -5'
To show the last two commits with one command, one might try
 1) git show -s master~2..
 2) git show -s ^master~2 master
 3) git show -s master^ master
 4) git show -s -2 master

Choice (3) works because both commits are listed on the command line. Choices (1) and (2) have worked ever since v1.6.4-rc~3 (Make 'git show' more useful, 2009-07-13) disabled --no-walk in this case because there is no other useful meaning for them to have. Unfortunately, (4) does not work: it outputs only one commit, because --no-walk stays on.

So disable --no-walk in this case so ‘git show’ and future ‘git cherry-pick’ can behave as expected.

As a side effect, this unfortunately changes the meaning of ‘git log --oneline --decorate --no-walk -5 --all’: instead of listing five refs, after this patch that command would list the five most recent commits.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 revision.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/revision.c b/revision.c
index f4b8b38..7b881a8 100644
--- a/revision.c
+++ b/revision.c
@@ -1063,18 +1063,22 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 
 	if (!prefixcmp(arg, "--max-count=")) {
 		revs->max_count = atoi(arg + 12);
+		revs->no_walk = 0;
 	} else if (!prefixcmp(arg, "--skip=")) {
 		revs->skip_count = atoi(arg + 7);
 	} else if ((*arg == '-') && isdigit(arg[1])) {
 	/* accept -<digit>, like traditional "head" */
 		revs->max_count = atoi(arg + 1);
+		revs->no_walk = 0;
 	} else if (!strcmp(arg, "-n")) {
 		if (argc <= 1)
 			return error("-n requires an argument");
 		revs->max_count = atoi(argv[1]);
+		revs->no_walk = 0;
 		return 2;
 	} else if (!prefixcmp(arg, "-n")) {
 		revs->max_count = atoi(arg + 2);
+		revs->no_walk = 0;
 	} else if (!prefixcmp(arg, "--max-age=")) {
 		revs->max_age = atoi(arg + 10);
 	} else if (!prefixcmp(arg, "--since=")) {
-- 
1.7.1.246.g2fc1b.dirty
Previous: Sverre RabbelierNext: Junio C Hamano
Message 13 of 30 in “implement cherry-picking many commits”
  1. 0/8 implement cherry-picking many commitsChristian Couder, May 31, 2010
  2. 1/8 revert: cleanup code for -x optionChristian Couder, May 31, 2010
  3. 2/8 revert: use run_command_v_opt() instead of execv_git_cmd()Christian Couder, May 31, 2010
  4. Jonathan NiederJun 1, 2010
  5. Christian CouderJun 1, 2010
  6. 3/8 revert: refactor code into a do_pick_commit() functionChristian Couder, May 31, 2010
  7. 4/8 revert: change help_msg() to take no argumentChristian Couder, May 31, 2010
  8. Jonathan NiederJun 1, 2010
  9. Jeff KingJun 1, 2010
  10. Jonathan NiederJun 1, 2010
  11. 5/8 revert: allow cherry-picking more than one commitChristian Couder, May 31, 2010
  12. Sverre RabbelierJun 1, 2010
  13. Jonathan NiederJun 1, 2010
  14. Junio C HamanoJun 2, 2010
  15. Christian CouderJun 3, 2010
  16. Jonathan NiederJun 1, 2010
  17. Christian CouderJun 2, 2010
  18. 6/8 revert: add tests to check cherry-picking many commitsChristian Couder, May 31, 2010
  19. 7/8 Documentation/cherry-pick: describe passing more than one commitChristian Couder, May 31, 2010
  20. Ramkumar RamachandraJun 1, 2010
  21. Christian CouderJun 2, 2010
  22. Jonathan NiederJun 1, 2010
  23. Ramkumar RamachandraJun 1, 2010
  24. Christian CouderJun 2, 2010
  25. Christian CouderJun 2, 2010
  26. Jonathan NiederJun 2, 2010
  27. Christian CouderJun 14, 2010
  28. 8/8 Documentation/revert: describe passing more than one commitChristian Couder, May 31, 2010
  29. Antriksh PanyJun 1, 2010
  30. Christian CouderJun 2, 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.