git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/1] freshen_file(): use NULL `times' for implicit current-time
@ 2020-04-14 14:27 luciano.rocha
  2020-04-14 19:55 ` Jeff King
  2020-04-15 21:36 ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: luciano.rocha @ 2020-04-14 14:27 UTC (permalink / raw)
  To: git, peff, gitster; +Cc: Luciano Rocha, Jeff King, Junio C Hamano

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>
---
 sha1-file.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sha1-file.c b/sha1-file.c
index 6926851724..ccd34dd9e8 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -881,9 +881,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);
 }
 
 /*
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-16  1:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 14:27 [PATCH 1/1] freshen_file(): use NULL `times' for implicit current-time luciano.rocha
2020-04-14 19:55 ` Jeff King
2020-04-15  9:09   ` [External] " luciano.rocha
2020-04-15 16:05     ` Jeff King
2020-04-15 17:30       ` Junio C Hamano
2020-04-15 21:36 ` Junio C Hamano
2020-04-15 23:48   ` brian m. carlson
2020-04-16  1:02     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).