]> git.ipfire.org Git - thirdparty/git.git/commitdiff
freshen_file(): use NULL `times' for implicit current-time
authorluciano.rocha@booking.com <luciano.rocha@booking.com>
Tue, 14 Apr 2020 14:27:26 +0000 (16:27 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Apr 2020 16:57:23 +0000 (09:57 -0700)
Update freshen_file() to use a NULL `times', semantically equivalent to
the currently setup, with an explicit `actime' and `modtime' set to the
"current time", but with the advantage that it works with other files
not owned by the current user.

Fixes an issue on shared repos with a split index, where eventually a
user's operation creates a shared index, and another user will later do
an operation that will try to update its freshness, but will instead
raise a warning:
  $ git status
  warning: could not freshen shared index '.git/sharedindex.bd736fa10e0519593fefdb2aec253534470865b2'

Signed-off-by: Luciano Miguel Ferreira Rocha <luciano.rocha@booking.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1-file.c

index 188de57634bb1b0b15fbe3ab97f062bed7927763..c468ef725057b9042f2ad5d8fe7a13febf5eff77 100644 (file)
@@ -868,9 +868,7 @@ void prepare_alt_odb(struct repository *r)
 /* Returns 1 if we have successfully freshened the file, 0 otherwise. */
 static int freshen_file(const char *fn)
 {
-       struct utimbuf t;
-       t.actime = t.modtime = time(NULL);
-       return !utime(fn, &t);
+       return !utime(fn, NULL);
 }
 
 /*