Message ID | pull.695.v5.git.1600366313.gitgitgadget@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Maintenance I: Command, gc and commit-graph tasks | expand |
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > Update in v4 > ============ > > A segfault when running just "git maintenance" is fixed. The net change is just a single liner below, and is obviously correct. I propagated it through to part #2 and part #3 locally, and hopefully this makes part #1 ready to go. Thanks. diff --git a/builtin/gc.c b/builtin/gc.c index c3bcdc1167..090959350e 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1027,7 +1027,8 @@ static const char builtin_maintenance_usage[] = N_("git maintenance run [<option int cmd_maintenance(int argc, const char **argv, const char *prefix) { - if (argc == 2 && !strcmp(argv[1], "-h")) + if (argc < 2 || + (argc == 2 && !strcmp(argv[1], "-h"))) usage(builtin_maintenance_usage); if (!strcmp(argv[1], "run")) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 4f6a04ddb1..53c883531e 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -10,7 +10,9 @@ test_expect_success 'help text' ' test_expect_code 129 git maintenance -h 2>err && test_i18ngrep "usage: git maintenance run" err && test_expect_code 128 git maintenance barf 2>err && - test_i18ngrep "invalid subcommand: barf" err + test_i18ngrep "invalid subcommand: barf" err && + test_expect_code 129 git maintenance 2>err && + test_i18ngrep "usage: git maintenance" err ' test_expect_success 'run [--auto|--quiet]' '
Hi Junio, On Thu, 17 Sep 2020, Junio C Hamano wrote: > "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > > > Update in v4 > > ============ > > > > A segfault when running just "git maintenance" is fixed. > > The net change is just a single liner below, and is obviously > correct. > > I propagated it through to part #2 and part #3 locally, and > hopefully this makes part #1 ready to go. Yay! > diff --git a/builtin/gc.c b/builtin/gc.c > index c3bcdc1167..090959350e 100644 > --- a/builtin/gc.c > +++ b/builtin/gc.c > @@ -1027,7 +1027,8 @@ static const char builtin_maintenance_usage[] = N_("git maintenance run [<option > > int cmd_maintenance(int argc, const char **argv, const char *prefix) > { > - if (argc == 2 && !strcmp(argv[1], "-h")) > + if (argc < 2 || > + (argc == 2 && !strcmp(argv[1], "-h"))) > usage(builtin_maintenance_usage); > > if (!strcmp(argv[1], "run")) > diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh > index 4f6a04ddb1..53c883531e 100755 > --- a/t/t7900-maintenance.sh > +++ b/t/t7900-maintenance.sh > @@ -10,7 +10,9 @@ test_expect_success 'help text' ' > test_expect_code 129 git maintenance -h 2>err && > test_i18ngrep "usage: git maintenance run" err && > test_expect_code 128 git maintenance barf 2>err && > - test_i18ngrep "invalid subcommand: barf" err > + test_i18ngrep "invalid subcommand: barf" err && > + test_expect_code 129 git maintenance 2>err && > + test_i18ngrep "usage: git maintenance" err > ' > > test_expect_success 'run [--auto|--quiet]' ' > Yep, that's how I read the range-diff, too. Ciao, Dscho