From: "René Scharfe" <l.s.r@web.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: "Martin Ågren" <martin.agren@gmail.com>,
"Thomas Rikl" <trikl@online.de>,
"Thomas Gummerer" <t.gummerer@gmail.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>
Subject: [PATCH 1/2] git: add NO_INTERNAL_HELP flag for builtins
Date: Tue, 17 Oct 2017 17:39:03 +0200 [thread overview]
Message-ID: <76c3e710-0655-7788-f6f4-af1e59d65edd@web.de> (raw)
In-Reply-To: <4d110305-0826-6fd1-91a5-c1ebd0b1e80b@web.de>
Builtin commands have skipped repo setup when called with just a single
option -h and thus shown their short help text even outside of
repositories since 99caeed05d3 (Let 'git <command> -h' show usage
without a git dir).
Add the flag NO_INTERNAL_HELP for builtins to opt out of this special
treatment and provide a list of commands that are exempt from the
corresponding test in t0012. That allows builtins to handle -h
themselves.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
git.c | 6 +++++-
t/t0012-help.sh | 9 ++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/git.c b/git.c
index 9e96dd4090..9d1b8c4716 100644
--- a/git.c
+++ b/git.c
@@ -298,6 +298,7 @@ static int handle_alias(int *argcp, const char ***argv)
#define NEED_WORK_TREE (1<<3)
#define SUPPORT_SUPER_PREFIX (1<<4)
#define DELAY_PAGER_CONFIG (1<<5)
+#define NO_INTERNAL_HELP (1<<6)
struct cmd_struct {
const char *cmd;
@@ -312,7 +313,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
const char *prefix;
prefix = NULL;
- help = argc == 2 && !strcmp(argv[1], "-h");
+ if (p->option & NO_INTERNAL_HELP)
+ help = 0;
+ else
+ help = argc == 2 && !strcmp(argv[1], "-h");
if (!help) {
if (p->option & RUN_SETUP)
prefix = setup_git_directory();
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 487b92a5de..74eeead168 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -53,12 +53,19 @@ test_expect_success 'generate builtin list' '
git --list-builtins >builtins
'
+cat >no_internal_help <<EOF
+EOF
+
+test_expect_success 'generate list of builtins with internal help' '
+ grep -w -v -f no_internal_help <builtins >builtins_internal_help
+'
+
while read builtin
do
test_expect_success "$builtin can handle -h" '
test_expect_code 129 git $builtin -h >output 2>&1 &&
test_i18ngrep usage output
'
-done <builtins
+done <builtins_internal_help
test_done
--
2.14.2
next prev parent reply other threads:[~2017-10-17 15:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-15 10:02 Bug: git ls-remote -h / --head results differ in output Thomas Rikl
2017-10-15 11:08 ` Martin Ågren
2017-10-15 13:26 ` René Scharfe
2017-10-17 15:39 ` René Scharfe [this message]
2017-10-17 17:39 ` [PATCH 1/2] git: add NO_INTERNAL_HELP flag for builtins Jonathan Nieder
2017-10-17 15:39 ` [PATCH 2/2] ls-remote: use PARSE_OPT_NO_INTERNAL_HELP René Scharfe
2017-10-17 17:42 ` Jonathan Nieder
2017-10-17 17:42 ` Martin Ågren
2017-10-17 15:39 ` [Alt. PATCH] ls-remote: deprecate -h as short for --heads René Scharfe
2017-10-17 17:40 ` Martin Ågren
2017-10-17 17:43 ` Jonathan Nieder
2017-10-17 23:22 ` Junio C Hamano
2017-10-19 18:26 ` René Scharfe
2017-10-19 20:32 ` Jeff King
2017-10-20 1:04 ` Junio C Hamano
2017-10-20 3:05 ` Jeff King
2017-10-20 5:35 ` Junio C Hamano
2017-10-21 7:16 ` Jeff King
2017-10-21 10:14 ` René Scharfe
2017-10-21 12:18 ` Junio C Hamano
2017-10-23 15:05 ` René Scharfe
2017-10-24 0:52 ` Junio C Hamano
2017-10-24 18:26 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76c3e710-0655-7788-f6f4-af1e59d65edd@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=martin.agren@gmail.com \
--cc=peff@peff.net \
--cc=t.gummerer@gmail.com \
--cc=trikl@online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).