builtin/gc: move `struct maintenance_run_opts`

We're about to start using `struct maintenance_run_opts` in `maintenance_task_pack_refs()`. Move its definition up to prepare for this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Mar 25, 2024 at 11:03 UTC 0e05d53992b85cd19ce5f3c5d476ded10e2b63e1
1 file changed +26 -27
builtin/gc.c
+26 -27
@@ -180,7 +180,32 @@ static void gc_config(void)
180 git_config(git_default_config, NULL);
181 }
182
183 -struct maintenance_run_opts;
183 +enum schedule_priority {
184 + SCHEDULE_NONE = 0,
185 + SCHEDULE_WEEKLY = 1,
186 + SCHEDULE_DAILY = 2,
187 + SCHEDULE_HOURLY = 3,
188 +};
189 +
190 +static enum schedule_priority parse_schedule(const char *value)
191 +{
192 + if (!value)
193 + return SCHEDULE_NONE;
194 + if (!strcasecmp(value, "hourly"))
195 + return SCHEDULE_HOURLY;
196 + if (!strcasecmp(value, "daily"))
197 + return SCHEDULE_DAILY;
198 + if (!strcasecmp(value, "weekly"))
199 + return SCHEDULE_WEEKLY;
200 + return SCHEDULE_NONE;
201 +}
202 +
203 +struct maintenance_run_opts {
204 + int auto_flag;
205 + int quiet;
206 + enum schedule_priority schedule;
207 +};
208 +
209 static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
210 {
211 struct child_process cmd = CHILD_PROCESS_INIT;
@@ -773,26 +798,6 @@ static const char *const builtin_maintenance_run_usage[] = {
798 NULL
799 };
800
776 -enum schedule_priority {
777 - SCHEDULE_NONE = 0,
778 - SCHEDULE_WEEKLY = 1,
779 - SCHEDULE_DAILY = 2,
780 - SCHEDULE_HOURLY = 3,
781 -};
782 -
783 -static enum schedule_priority parse_schedule(const char *value)
784 -{
785 - if (!value)
786 - return SCHEDULE_NONE;
787 - if (!strcasecmp(value, "hourly"))
788 - return SCHEDULE_HOURLY;
789 - if (!strcasecmp(value, "daily"))
790 - return SCHEDULE_DAILY;
791 - if (!strcasecmp(value, "weekly"))
792 - return SCHEDULE_WEEKLY;
793 - return SCHEDULE_NONE;
794 -}
795 -
801 static int maintenance_opt_schedule(const struct option *opt, const char *arg,
802 int unset)
803 {
@@ -809,12 +814,6 @@ static int maintenance_opt_schedule(const struct option *opt, const char *arg,
814 return 0;
815 }
816
812 -struct maintenance_run_opts {
813 - int auto_flag;
814 - int quiet;
815 - enum schedule_priority schedule;
816 -};
817 -
817 /* Remember to update object flag allocation in object.h */
818 #define SEEN (1u<<0)
819