summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2014-06-18 15:56:48 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-06-20 10:45:19 -0700
commit6d87780399e1196932cd5ea72f84aa90224e7402 (patch)
tree60383d002c2ca86a920a0f8df186c8e649a6495a
parentfetch-pack: refactor parsing in get_ack (diff)
downloadtgif-6d87780399e1196932cd5ea72f84aa90224e7402.tar.xz
git: avoid magic number with skip_prefix
After handling options, any leftover arguments should be commands. However, we pass through "--help" and "--version", so that we convert them into "git help" and "git version" respectively. This is a straightforward use of skip_prefix to avoid a magic number, but while we are there, it is worth adding a comment to explain this otherwise confusing behavior. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--git.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/git.c b/git.c
index b2bb09e40a..1537f00bc7 100644
--- a/git.c
+++ b/git.c
@@ -588,8 +588,8 @@ int main(int argc, char **av)
argc--;
handle_options(&argv, &argc, NULL);
if (argc > 0) {
- if (starts_with(argv[0], "--"))
- argv[0] += 2;
+ /* translate --help and --version into commands */
+ skip_prefix(argv[0], "--", &argv[0]);
} else {
/* The user didn't specify a command; give them help */
commit_pager_choice();