From: Junio C Hamano Date: Wed, 6 Dec 2017 17:23:37 +0000 (-0800) Subject: Merge branch 'hm/config-parse-expiry-date' X-Git-Tag: v2.16.0-rc0~81 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6cddb7362ca3c7312b57a4f172bca5c953a45b6c?hp=-c Merge branch 'hm/config-parse-expiry-date' "git config --expiry-date gc.reflogexpire" can read "2.weeks" from the configuration and report it as a timestamp, just like "--int" would read "1k" and report 1024, to help consumption by scripts. * hm/config-parse-expiry-date: config: add --expiry-date --- 6cddb7362ca3c7312b57a4f172bca5c953a45b6c diff --combined config.c index 676786a028,64f8aa42be..e617c2018d --- a/config.c +++ b/config.c @@@ -990,6 -990,16 +990,16 @@@ int git_config_pathname(const char **de return 0; } + int git_config_expiry_date(timestamp_t *timestamp, const char *var, const char *value) + { + if (!value) + return config_error_nonbool(var); + if (parse_expiry_date(value, timestamp)) + return error(_("'%s' for '%s' is not a valid timestamp"), + value, var); + return 0; + } + static int git_default_core_config(const char *var, const char *value) { /* This needs a better name */ @@@ -2156,20 -2166,6 +2166,20 @@@ int git_config_get_max_percent_split_ch return -1; /* default value */ } +int git_config_get_fsmonitor(void) +{ + if (git_config_get_pathname("core.fsmonitor", &core_fsmonitor)) + core_fsmonitor = getenv("GIT_FSMONITOR_TEST"); + + if (core_fsmonitor && !*core_fsmonitor) + core_fsmonitor = NULL; + + if (core_fsmonitor) + return 1; + + return 0; +} + NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr) { @@@ -2329,7 -2325,7 +2339,7 @@@ static ssize_t write_section(int fd, co struct strbuf sb = store_create_section(key); ssize_t ret; - ret = write_in_full(fd, sb.buf, sb.len) == sb.len; + ret = write_in_full(fd, sb.buf, sb.len); strbuf_release(&sb); return ret; @@@ -2824,7 -2820,7 +2834,7 @@@ static int git_config_copy_or_rename_se * multiple [branch "$name"] sections. */ if (copystr.len > 0) { - if (write_in_full(out_fd, copystr.buf, copystr.len) != copystr.len) { + if (write_in_full(out_fd, copystr.buf, copystr.len) < 0) { ret = write_error(get_lock_file_path(&lock)); goto out; } @@@ -2886,7 -2882,7 +2896,7 @@@ * logic in the loop above. */ if (copystr.len > 0) { - if (write_in_full(out_fd, copystr.buf, copystr.len) != copystr.len) { + if (write_in_full(out_fd, copystr.buf, copystr.len) < 0) { ret = write_error(get_lock_file_path(&lock)); goto out; } diff --combined config.h index 524d411823,fc66c59332..ef70a9cac1 --- a/config.h +++ b/config.h @@@ -58,6 -58,7 +58,7 @@@ extern int git_config_bool_or_int(cons extern int git_config_bool(const char *, const char *); extern int git_config_string(const char **, const char *, const char *); extern int git_config_pathname(const char **, const char *, const char *); + extern int git_config_expiry_date(timestamp_t *, const char *, const char *); extern int git_config_set_in_file_gently(const char *, const char *, const char *); extern void git_config_set_in_file(const char *, const char *, const char *); extern int git_config_set_gently(const char *, const char *); @@@ -212,7 -213,6 +213,7 @@@ extern int git_config_get_pathname(cons extern int git_config_get_untracked_cache(void); extern int git_config_get_split_index(void); extern int git_config_get_max_percent_split_change(void); +extern int git_config_get_fsmonitor(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);