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>

Jeff King committed Jun 18, 2014 at 15:56 UTC 6d87780399e1196932cd5ea72f84aa90224e7402
1 file changed +2 -2
git.c
+2 -2
@@ -588,8 +588,8 @@ int main(int argc, char **av)
588 argc--;
589 handle_options(&argv, &argc, NULL);
590 if (argc > 0) {
591 - if (starts_with(argv[0], "--"))
592 - argv[0] += 2;
591 + /* translate --help and --version into commands */
592 + skip_prefix(argv[0], "--", &argv[0]);
593 } else {
594 /* The user didn't specify a command; give them help */
595 commit_pager_choice();