accept non-integer for "this many days" expiry specification
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest6 patches 0 repliesNew
- v12 patches 2 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | t4200: give us a clean slate after "rerere gc" testst/ | +2 | 0 replies | |
| 2/6 | t4200: make "rerere gc" test more robustt/ | +14 | 0 replies | |
| 3/6 | t4200: gather "rerere gc" togethert/ | +27 | 0 replies | |
| 4/6 | t4200: parameterize "rerere gc" custom expiry testt/ | +33 | 0 replies | |
| 5/6 | rerere: represent time duration in timestamp_t internallyrerere.c | +23 | 0 replies | |
| 6/6 | rerere: allow approxidate in gc.rerereResolved/gc.rerereUnresolvedDocumentation/ config.c config.h +2 more | +31 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/6] accept non-integer for "this many days" expiry specification
About a month ago, we wondered why
[gc] rerereResolved = 5.days
does not work and if we want to do something better.
This is an update to my first attempt. It turns out that I needed more patches to clean up the tests before I can write new tests for this feature.
The implementation of the feature itself has not changed much, except that it now lives in config.c for easier reuse by other codepaths in the future.
Junio C Hamano (6):
t4200: give us a clean slate after "rerere gc" tests
t4200: make "rerere gc" test more robust
t4200: gather "rerere gc" together
t4200: parameterize "rerere gc" custom expiry test
rerere: represent time duration in timestamp_t internally
rerere: allow approxidate in gc.rerereResolved/gc.rerereUnresolved
Documentation/config.txt | 2 ++ config.c | 22 +++++++++++++++++++ config.h | 3 +++ rerere.c | 26 +++++++++++----------- t/t4200-rerere.sh | 57 +++++++++++++++++++++++++++++++++--------------- 5 files changed, 79 insertions(+), 31 deletions(-)
The interdiff between the original one and this version looks like this.
config.c | 26 +++++++++++++++++++++++-- config.h | 6 +++--- rerere.c | 24 ++--------------------- t/t4200-rerere.sh | 57 +++++++++++++++++++++++++++++++++++++------------------ 4 files changed, 68 insertions(+), 45 deletions(-)
config.c +24 -2
@@ -769,7 +769,7 @@ static int parse_unit_factor(const char *end, uintmax_t *val)return 0 ; } -int git_parse_signed (const char *value,intmax_t *ret,intmax_t max) +static int git_parse_signed (const char *value,intmax_t *ret,intmax_t max) {if (value && *value) {char *end;
@@ -799,7 +799,7 @@ int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)return 0 ; } -int git_parse_unsigned (const char *value,uintmax_t *ret,uintmax_t max) +static int git_parse_unsigned (const char *value,uintmax_t *ret,uintmax_t max) {if (value && *value) {char *end;
@@ -2066,6 +2066,28 @@ int git_config_get_expiry(const char *key, const char **output)return ret; } +int git_config_get_expiry_in_days (const char *key,timestamp_t *expiry,timestamp_t now) +{ +char *expiry_string; +intmax_t days; +timestamp_t when; + +if (git_config_get_string (key, &expiry_string)) +return 1 ;/* no such thing */ + +if (git_parse_signed (expiry_string, &days,maximum_signed_value_of_type (int))) { +const int scale =86400 ; + *expiry = now - days * scale; +return 0 ; + } + +if (!parse_expiry_date (expiry_string, &when)) { + *expiry = when; +return 0 ; + } +return -1 ;/* thing exists but cannot be parsed */ +} +int git_config_get_untracked_cache (void ) {int val =-1 ;
config.h +3 -3
@@ -205,6 +205,9 @@ extern int git_config_get_max_percent_split_change(void);/* This dies if the configured or default date is in the future */ extern int git_config_get_expiry (const char *key,const char **output); +/* parse either "this many days" integer, or "5.days.ago" approxidate */ +extern int git_config_get_expiry_in_days (const char *key,timestamp_t *,timestamp_t now); +struct key_value_info {const char *filename;int linenr;
@@ -215,7 +218,4 @@ struct key_value_info { extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); -int git_parse_unsigned (const char *value,uintmax_t *ret,uintmax_t max); -int git_parse_signed (const char *value,intmax_t *ret,intmax_t max); -#endif /* CONFIG_H */
rerere.c +2 -22
@@ -1176,26 +1176,6 @@ static void prune_one(struct rerere_id *id,unlink_rr_item (id); } -static void config_get_expiry (const char *key,timestamp_t *cutoff,timestamp_t now) -{ -char *expiry_string; -intmax_t days; -timestamp_t when; - -if (git_config_get_string (key, &expiry_string)) -return ; - -if (git_parse_signed (expiry_string, &days,maximum_signed_value_of_type (int))) { -const int scale =86400 ; - *cutoff = now - days * scale; -return ; - } - -if (!parse_expiry_date (expiry_string, &when)) { - *cutoff = when; - } -} -void rerere_gc (struct string_list *rr) {struct string_list to_remove =STRING_LIST_INIT_DUP ;
@@ -1209,8 +1189,8 @@ void rerere_gc(struct string_list *rr)if (setup_rerere (rr,0 ) <0 )return ; -config_get_expiry ("gc.rerereresolved" , &cutoff_resolve, now); -config_get_expiry ("gc.rerereunresolved" , &cutoff_noresolve, now); +git_config_get_expiry_in_days ("gc.rerereresolved" , &cutoff_resolve, now); +git_config_get_expiry_in_days ("gc.rerereunresolved" , &cutoff_noresolve, now);git_config (git_default_config,NULL ); dir =opendir (git_path ("rr-cache" ));if (!dir)
t/t4200-rerere.sh +39 -18
75 lines not on this page · raw message