Thread (7 messages) flat view 7 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH 4/4] builtin/show: do not prune by pathspec

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:57
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

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 <redacted>
---
 builtin/log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 916019c..474a76d 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -420,6 +420,8 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	opt.def = "HEAD";
 	opt.tweak = show_rev_tweak_rev;
 	cmd_log_init(argc, argv, prefix, &rev, &opt);
+	if (rev.no_walk)
+		rev.prune = 0;
 
 	count = rev.pending.nr;
 	objects = rev.pending.objects;
-- 
1.7.4.2.668.gba03a4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help