Skip to content

Commit d7add50

Browse files
Michael J Grubermjg
authored andcommitted
builtin/show: do not prune by pathspec
By design, "git show commit -- path" is not "git show commit:path", and there is no reason to change that. But "git show commit -- path" simply returns nothing at all "most of the time" because it prunes by pathspec even though it does not walk commits. This is pretty useless. So, turn off commit pruning (but keep diff limiting of course) so that "git show commit -- path" shows the commit message and the diff that the commit introduces to path (filtered by path); only the diff will be empty "most of the time". As an intended side effect, users mistaking "git show commit -- path" for "git show commit:path" are automatically reminded that they asked git to show a commit, not a blob. In case the user has specified "--do-walk", assume they want the old behaviour (prune by default).
1 parent 1f87b77 commit d7add50

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ int cmd_show(int argc,
687687
opt.def = "HEAD";
688688
opt.tweak = show_setup_revisions_tweak;
689689
cmd_log_init(argc, argv, prefix, &rev, &opt, &cfg);
690+
if (rev.no_walk)
691+
rev.prune = 0;
690692

691693
if (!rev.no_walk) {
692694
ret = cmd_log_walk(&rev);

0 commit comments

Comments
 (0)