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
This commit is contained in:
@ -5,6 +5,7 @@ static const char *usage_msg = "\n"
|
||||
" test-date show:<format> [time_t]...\n"
|
||||
" test-date parse [date]...\n"
|
||||
" test-date approxidate [date]...\n"
|
||||
" test-date timestamp [date]...\n"
|
||||
" test-date is64bit\n"
|
||||
" test-date time_t-is64bit\n";
|
||||
|
||||
@ -71,6 +72,15 @@ static void parse_approxidate(const char **argv, struct timeval *now)
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_approx_timestamp(const char **argv, struct timeval *now)
|
||||
{
|
||||
for (; *argv; argv++) {
|
||||
timestamp_t t;
|
||||
t = approxidate_relative(*argv, now);
|
||||
printf("%s -> %"PRItime"\n", *argv, t);
|
||||
}
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
{
|
||||
struct timeval now;
|
||||
@ -95,6 +105,8 @@ int cmd_main(int argc, const char **argv)
|
||||
parse_dates(argv+1, &now);
|
||||
else if (!strcmp(*argv, "approxidate"))
|
||||
parse_approxidate(argv+1, &now);
|
||||
else if (!strcmp(*argv, "timestamp"))
|
||||
parse_approx_timestamp(argv+1, &now);
|
||||
else if (!strcmp(*argv, "is64bit"))
|
||||
return sizeof(timestamp_t) == 8 ? 0 : 1;
|
||||
else if (!strcmp(*argv, "time_t-is64bit"))
|
||||
|
@ -901,6 +901,36 @@ test_expect_success 'get --path barfs on boolean variable' '
|
||||
test_must_fail git config --get --path path.bool
|
||||
'
|
||||
|
||||
test_expect_success 'get --expiry-date' '
|
||||
rel="3.weeks.5.days.00:00" &&
|
||||
rel_out="$rel ->" &&
|
||||
cat >.git/config <<-\EOF &&
|
||||
[date]
|
||||
valid1 = "3.weeks.5.days 00:00"
|
||||
valid2 = "Fri Jun 4 15:46:55 2010"
|
||||
valid3 = "2017/11/11 11:11:11PM"
|
||||
valid4 = "2017/11/10 09:08:07 PM"
|
||||
valid5 = "never"
|
||||
invalid1 = "abc"
|
||||
EOF
|
||||
cat >expect <<-EOF &&
|
||||
$(test-date timestamp $rel)
|
||||
1275666415
|
||||
1510441871
|
||||
1510348087
|
||||
0
|
||||
EOF
|
||||
{
|
||||
echo "$rel_out $(git config --expiry-date date.valid1)"
|
||||
git config --expiry-date date.valid2 &&
|
||||
git config --expiry-date date.valid3 &&
|
||||
git config --expiry-date date.valid4 &&
|
||||
git config --expiry-date date.valid5
|
||||
} >actual &&
|
||||
test_cmp expect actual &&
|
||||
test_must_fail git config --expiry-date date.invalid1
|
||||
'
|
||||
|
||||
cat > expect << EOF
|
||||
[quote]
|
||||
leading = " test"
|
||||
|
Reference in New Issue
Block a user