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>
This commit is contained in:

committed by
Junio C Hamano

parent
82e56767aa
commit
6d87780399
4
git.c
4
git.c
@ -588,8 +588,8 @@ int main(int argc, char **av)
|
|||||||
argc--;
|
argc--;
|
||||||
handle_options(&argv, &argc, NULL);
|
handle_options(&argv, &argc, NULL);
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
if (starts_with(argv[0], "--"))
|
/* translate --help and --version into commands */
|
||||||
argv[0] += 2;
|
skip_prefix(argv[0], "--", &argv[0]);
|
||||||
} else {
|
} else {
|
||||||
/* The user didn't specify a command; give them help */
|
/* The user didn't specify a command; give them help */
|
||||||
commit_pager_choice();
|
commit_pager_choice();
|
||||||
|
Reference in New Issue
Block a user