return result;
}
+enum maintenance_type {
+ /* As invoked via `git maintenance run --schedule=`. */
+ MAINTENANCE_TYPE_SCHEDULED = (1 << 0),
+ /* As invoked via `git maintenance run` and with `--auto`. */
+ MAINTENANCE_TYPE_MANUAL = (1 << 1),
+};
+
struct maintenance_strategy {
struct {
- int enabled;
+ unsigned type;
enum schedule_priority schedule;
} tasks[TASK__COUNT];
};
static const struct maintenance_strategy default_strategy = {
.tasks = {
[TASK_GC] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_MANUAL,
},
},
};
static const struct maintenance_strategy incremental_strategy = {
.tasks = {
[TASK_COMMIT_GRAPH] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_SCHEDULED,
.schedule = SCHEDULE_HOURLY,
},
[TASK_PREFETCH] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_SCHEDULED,
.schedule = SCHEDULE_HOURLY,
},
[TASK_INCREMENTAL_REPACK] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_SCHEDULED,
.schedule = SCHEDULE_DAILY,
},
[TASK_LOOSE_OBJECTS] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_SCHEDULED,
.schedule = SCHEDULE_DAILY,
},
[TASK_PACK_REFS] = {
- .enabled = 1,
+ .type = MAINTENANCE_TYPE_SCHEDULED,
.schedule = SCHEDULE_WEEKLY,
},
},
{
struct strbuf config_name = STRBUF_INIT;
struct maintenance_strategy strategy;
+ enum maintenance_type type;
const char *config_str;
/*
strategy = parse_maintenance_strategy(config_str);
else
strategy = none_strategy;
+ type = MAINTENANCE_TYPE_SCHEDULED;
} else {
strategy = default_strategy;
+ type = MAINTENANCE_TYPE_MANUAL;
}
for (size_t i = 0; i < TASK__COUNT; i++) {
strbuf_addf(&config_name, "maintenance.%s.enabled",
tasks[i].name);
if (!repo_config_get_bool(the_repository, config_name.buf, &config_value))
- strategy.tasks[i].enabled = config_value;
- if (!strategy.tasks[i].enabled)
+ strategy.tasks[i].type = config_value ? type : 0;
+ if (!(strategy.tasks[i].type & type))
continue;
if (opts->schedule) {