From e473bdad6ce6b2fbf00575e6d49293821c16bb75 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 31 Mar 2011 11:08:57 +0200 Subject: [PATCH] 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). Signed-off-by: Michael J Gruber --- builtin/log.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index db3a88bfe96058..584bd2a6c239ff 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -757,6 +757,8 @@ int cmd_show(int argc, const char **argv, const char *prefix) opt.def = "HEAD"; opt.tweak = show_setup_revisions_tweak; cmd_log_init(argc, argv, prefix, &rev, &opt); + if (rev.no_walk) + rev.prune = 0; if (!rev.no_walk) return cmd_log_deinit(cmd_log_walk(&rev), &rev);