Skip to content

Commit 6d87780

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 82e5676 commit 6d87780

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

git.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,8 @@ int main(int argc, char **av)
588588
argc--;
589589
handle_options(&argv, &argc, NULL);
590590
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]);
593593
} else {
594594
/* The user didn't specify a command; give them help */
595595
commit_pager_choice();

0 commit comments

Comments
 (0)