Thread (34 messages) flat view 34 messages, 3 authors, 2016-06-15
STALE3738d

[PATCH 03/24] Show usage string for 'git cherry -h'

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:47:41
Subsystem: the rest · Maintainer: Linus Torvalds

Treat an "-h" option as a request for help, rather than an
"Unknown commit -h" error.

"cherry -h" could be asking to compare histories that leads to
our HEAD and a commit that can be named as "-h".  Strictly
speaking, that may be a valid refname, but the user would have to
say something like "tags/-h" to name such a pathological ref
already, so it is not such a big deal.

The "-h" option keeps its meaning even if preceded by other
options or followed by other arguments.  This keeps the
command-line syntax closer to what parse_options would give and
supports shell aliases like 'alias cherry="git cherry -v"' a
little better.

Signed-off-by: Jonathan Nieder <redacted>
---
 builtin-log.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 207a361..5248507 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -1237,6 +1237,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
 		argv++;
 	}
 
+	if (argc > 1 && !strcmp(argv[1], "-h"))
+		usage(cherry_usage);
+
 	switch (argc) {
 	case 4:
 		limit = argv[3];
-- 
1.6.5.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help