@@ -88,113 +88,6 @@ static int collect_reflog(const char *ref, void *cb_data)
8888 return 0 ;
8989}
9090
91- static struct reflog_expire_entry_option * find_cfg_ent (struct reflog_expire_options * opts ,
92- const char * pattern , size_t len )
93- {
94- struct reflog_expire_entry_option * ent ;
95-
96- if (!opts -> entries_tail )
97- opts -> entries_tail = & opts -> entries ;
98-
99- for (ent = opts -> entries ; ent ; ent = ent -> next )
100- if (!xstrncmpz (ent -> pattern , pattern , len ))
101- return ent ;
102-
103- FLEX_ALLOC_MEM (ent , pattern , pattern , len );
104- * opts -> entries_tail = ent ;
105- opts -> entries_tail = & (ent -> next );
106- return ent ;
107- }
108-
109- /* expiry timer slot */
110- #define EXPIRE_TOTAL 01
111- #define EXPIRE_UNREACH 02
112-
113- static int reflog_expire_config (const char * var , const char * value ,
114- const struct config_context * ctx , void * cb )
115- {
116- struct reflog_expire_options * opts = cb ;
117- const char * pattern , * key ;
118- size_t pattern_len ;
119- timestamp_t expire ;
120- int slot ;
121- struct reflog_expire_entry_option * ent ;
122-
123- if (parse_config_key (var , "gc" , & pattern , & pattern_len , & key ) < 0 )
124- return git_default_config (var , value , ctx , cb );
125-
126- if (!strcmp (key , "reflogexpire" )) {
127- slot = EXPIRE_TOTAL ;
128- if (git_config_expiry_date (& expire , var , value ))
129- return -1 ;
130- } else if (!strcmp (key , "reflogexpireunreachable" )) {
131- slot = EXPIRE_UNREACH ;
132- if (git_config_expiry_date (& expire , var , value ))
133- return -1 ;
134- } else
135- return git_default_config (var , value , ctx , cb );
136-
137- if (!pattern ) {
138- switch (slot ) {
139- case EXPIRE_TOTAL :
140- opts -> default_expire_total = expire ;
141- break ;
142- case EXPIRE_UNREACH :
143- opts -> default_expire_unreachable = expire ;
144- break ;
145- }
146- return 0 ;
147- }
148-
149- ent = find_cfg_ent (opts , pattern , pattern_len );
150- if (!ent )
151- return -1 ;
152- switch (slot ) {
153- case EXPIRE_TOTAL :
154- ent -> expire_total = expire ;
155- break ;
156- case EXPIRE_UNREACH :
157- ent -> expire_unreachable = expire ;
158- break ;
159- }
160- return 0 ;
161- }
162-
163- static void set_reflog_expiry_param (struct reflog_expire_options * cb , const char * ref )
164- {
165- struct reflog_expire_entry_option * ent ;
166-
167- if (cb -> explicit_expiry == (EXPIRE_TOTAL |EXPIRE_UNREACH ))
168- return ; /* both given explicitly -- nothing to tweak */
169-
170- for (ent = cb -> entries ; ent ; ent = ent -> next ) {
171- if (!wildmatch (ent -> pattern , ref , 0 )) {
172- if (!(cb -> explicit_expiry & EXPIRE_TOTAL ))
173- cb -> expire_total = ent -> expire_total ;
174- if (!(cb -> explicit_expiry & EXPIRE_UNREACH ))
175- cb -> expire_unreachable = ent -> expire_unreachable ;
176- return ;
177- }
178- }
179-
180- /*
181- * If unconfigured, make stash never expire
182- */
183- if (!strcmp (ref , "refs/stash" )) {
184- if (!(cb -> explicit_expiry & EXPIRE_TOTAL ))
185- cb -> expire_total = 0 ;
186- if (!(cb -> explicit_expiry & EXPIRE_UNREACH ))
187- cb -> expire_unreachable = 0 ;
188- return ;
189- }
190-
191- /* Nothing matched -- use the default value */
192- if (!(cb -> explicit_expiry & EXPIRE_TOTAL ))
193- cb -> expire_total = cb -> default_expire_total ;
194- if (!(cb -> explicit_expiry & EXPIRE_UNREACH ))
195- cb -> expire_unreachable = cb -> default_expire_unreachable ;
196- }
197-
19891static int expire_unreachable_callback (const struct option * opt ,
19992 const char * arg ,
20093 int unset )
@@ -207,7 +100,7 @@ static int expire_unreachable_callback(const struct option *opt,
207100 die (_ ("invalid timestamp '%s' given to '--%s'" ),
208101 arg , opt -> long_name );
209102
210- opts -> explicit_expiry |= EXPIRE_UNREACH ;
103+ opts -> explicit_expiry |= REFLOG_EXPIRE_UNREACH ;
211104 return 0 ;
212105}
213106
@@ -223,7 +116,7 @@ static int expire_total_callback(const struct option *opt,
223116 die (_ ("invalid timestamp '%s' given to '--%s'" ),
224117 arg , opt -> long_name );
225118
226- opts -> explicit_expiry |= EXPIRE_TOTAL ;
119+ opts -> explicit_expiry |= REFLOG_EXPIRE_TOTAL ;
227120 return 0 ;
228121}
229122
@@ -353,7 +246,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
353246 .dry_run = !!(flags & EXPIRE_REFLOGS_DRY_RUN ),
354247 };
355248
356- set_reflog_expiry_param (& cb .opts , item -> string );
249+ reflog_expire_options_set_refname (& cb .opts , item -> string );
357250 status |= refs_reflog_expire (get_main_ref_store (the_repository ),
358251 item -> string , flags ,
359252 reflog_expiry_prepare ,
@@ -372,7 +265,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
372265 status |= error (_ ("%s points nowhere!" ), argv [i ]);
373266 continue ;
374267 }
375- set_reflog_expiry_param (& cb .opts , ref );
268+ reflog_expire_options_set_refname (& cb .opts , ref );
376269 status |= refs_reflog_expire (get_main_ref_store (the_repository ),
377270 ref , flags ,
378271 reflog_expiry_prepare ,
0 commit comments