diff options
author | Haaris Mehmood <hsed@unimetic.com> | 2017-11-18 03:27:27 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-18 04:31:29 +0100 |
commit | 5f9674243d0341519e5031681c941b0e1ad7a9e3 (patch) | |
tree | 26e797cc693541bcd3eaaa83c610894bb2982ae5 /config.c | |
parent | Sync with maint (diff) | |
download | git-5f9674243d0341519e5031681c941b0e1ad7a9e3.tar.xz git-5f9674243d0341519e5031681c941b0e1ad7a9e3.zip |
config: add --expiry-date
Add --expiry-date as a data-type for config files when
'git config --get' is used. This will return any relative
or fixed dates from config files as timestamps.
This is useful for scripts (e.g. gc.reflogexpire) that work
with timestamps so that '2.weeks' can be converted to a format
acceptable by those scripts/functions.
Following the convention of git_config_pathname(), move
the helper function required for this feature from
builtin/reflog.c to builtin/config.c where other similar
functions exist (e.g. for --bool or --path), and match
the order of parameters with other functions (i.e. output
pointer as first parameter).
Signed-off-by: Haaris Mehmood <hsed@unimetic.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -990,6 +990,16 @@ int git_config_pathname(const char **dest, const char *var, const char *value) 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 */ |