Skip to content

Commit 5853cae

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 225c93a commit 5853cae

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

revision.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,22 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
10631063

10641064
if (!prefixcmp(arg, "--max-count=")) {
10651065
revs->max_count = atoi(arg + 12);
1066+
revs->no_walk = 0;
10661067
} else if (!prefixcmp(arg, "--skip=")) {
10671068
revs->skip_count = atoi(arg + 7);
10681069
} else if ((*arg == '-') && isdigit(arg[1])) {
10691070
/* accept -<digit>, like traditional "head" */
10701071
revs->max_count = atoi(arg + 1);
1072+
revs->no_walk = 0;
10711073
} else if (!strcmp(arg, "-n")) {
10721074
if (argc <= 1)
10731075
return error("-n requires an argument");
10741076
revs->max_count = atoi(argv[1]);
1077+
revs->no_walk = 0;
10751078
return 2;
10761079
} else if (!prefixcmp(arg, "-n")) {
10771080
revs->max_count = atoi(arg + 2);
1081+
revs->no_walk = 0;
10781082
} else if (!prefixcmp(arg, "--max-age=")) {
10791083
revs->max_age = atoi(arg + 10);
10801084
} else if (!prefixcmp(arg, "--since=")) {

0 commit comments

Comments
 (0)