Skip to content

Commit a7c86d3

Browse files
pks-tgitster
authored andcommitted
builtin/maintenance: mark "--task=" and "--schedule=" as incompatible
The "--task=" option explicitly allows the user to say which maintenance tasks should be run, whereas "--schedule=" only respects the maintenance strategy configured for a specific repository. As such, it is not sensible to accept both options at the same time. Mark them as incompatible with one another. While at it, also convert the existing logic that marks "--auto" and "--schedule=" as incompatible to use `die_for_incompatible_opt2()`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1bb6bdb commit a7c86d3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

builtin/gc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,8 +1785,10 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
17851785
builtin_maintenance_run_usage,
17861786
PARSE_OPT_STOP_AT_NON_OPTION);
17871787

1788-
if (opts.auto_flag && opts.schedule)
1789-
die(_("use at most one of --auto and --schedule=<frequency>"));
1788+
die_for_incompatible_opt2(opts.auto_flag, "--auto",
1789+
opts.schedule, "--schedule=");
1790+
die_for_incompatible_opt2(selected_tasks.nr, "--task=",
1791+
opts.schedule, "--schedule=");
17901792

17911793
gc_config(&cfg);
17921794
initialize_task_config(&selected_tasks, opts.schedule);

t/t7900-maintenance.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,12 @@ test_expect_success 'rerere-gc task with --auto honors maintenance.rerere-gc.aut
610610

611611
test_expect_success '--auto and --schedule incompatible' '
612612
test_must_fail git maintenance run --auto --schedule=daily 2>err &&
613-
test_grep "at most one" err
613+
test_grep "cannot be used together" err
614+
'
615+
616+
test_expect_success '--task and --schedule incompatible' '
617+
test_must_fail git maintenance run --task=pack-refs --schedule=daily 2>err &&
618+
test_grep "cannot be used together" err
614619
'
615620

616621
test_expect_success 'invalid --schedule value' '

0 commit comments

Comments
 (0)