t/helper: 'test-chmtime (--get|-g)' to print only the mtime
Compared to 'test-chmtime -v +0 file' which prints the mtime and
and the file name, 'test-chmtime --get file' displays only the mtime.
If it is used in combination with (+|=|=+|=-|-)seconds, it changes
and prints the new value.
test-chmtime -v +0 file | sed 's/[^0-9].*$//'
is now equivalent to:
test-chmtime --get file
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Paul-Sebastian Ungureanu7 years agocommitted byJunio C Hamano
static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
{
@ -46,7 +56,6 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
@@ -46,7 +56,6 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
}
*set_time = strtol(timespec, &test, 10);
if (*test) {
fprintf(stderr, "Not a base-10 integer: %s\n", arg + 1);
return 0;
}
if ((*set_eq && *set_time < 0) || *set_eq == 2) {
@ -59,6 +68,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
@@ -59,6 +68,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
int cmd_main(int argc, const char **argv)
{
static int verbose;
static int get;
int i = 1;
/* no mtime change by default */
@ -68,18 +78,34 @@ int cmd_main(int argc, const char **argv)
@@ -68,18 +78,34 @@ int cmd_main(int argc, const char **argv)
@ -73,8 +73,8 @@ test_expect_success 'do not touch files that are already up-to-date' '
@@ -73,8 +73,8 @@ test_expect_success 'do not touch files that are already up-to-date' '
@ -247,9 +247,9 @@ test_expect_success '--abort after last commit in sequence' '
@@ -247,9 +247,9 @@ test_expect_success '--abort after last commit in sequence' '
test_expect_success 'cherry-pick does not implicitly stomp an existing operation' '
test_expect_success 'avoid unnecessary update, normal rename' '
git checkout -q avoid-unnecessary-update-1^0 &&
test-chmtime =1000000000 rename &&
test-chmtime -v +0 rename >expect &&
test-chmtime --get =1000000000 rename >expect &&
git merge merge-branch-1 &&
test-chmtime -v +0 rename >actual &&
test-chmtime --get rename >actual &&
test_cmp expect actual # "rename" should have stayed intact
'
@ -668,10 +667,9 @@ test_expect_success 'setup to test avoiding unnecessary update, with D/F conflic
@@ -668,10 +667,9 @@ test_expect_success 'setup to test avoiding unnecessary update, with D/F conflic
test_expect_success 'avoid unnecessary update, with D/F conflict' '
git checkout -q avoid-unnecessary-update-2^0 &&
test-chmtime =1000000000 df &&
test-chmtime -v +0 df >expect &&
test-chmtime --get =1000000000 df >expect &&
git merge merge-branch-2 &&
test-chmtime -v +0 df >actual &&
test-chmtime --get df >actual &&
test_cmp expect actual # "df" should have stayed intact
@ -1674,10 +1674,10 @@ test_expect_success '"Initial commit" should not be noted in commit template' '
@@ -1674,10 +1674,10 @@ test_expect_success '"Initial commit" should not be noted in commit template' '
test_expect_success '--no-optional-locks prevents index update' '