git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] freshen_file(): use NULL `times' for implicit current-time

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 15, 2020, 21:36 UTC
Message-ID
<xmqq4ktk5t4h.fsf@gitster.c.googlers.com>
In-Reply-To
<5e95d37d.1c69fb81.2b4ec.ce9f@mx.google.com>
luciano.rocha@booking.com writes:
Show 11 quoted lines
> 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'
A couple of questions:
 - Does utime(fn, NULL) work for any non-owner user, or does the
   user need to have write access to it?
 - If the answer is not "you need to be able to write", doesn't the
   bug lie elsewhere, namely, why .git/sharedindex.* not writable by
   the current user, if it is a shared repository setting?
Thanks.
Show 20 quoted lines
> 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);
>  }
>  
>  /*
Previous: Junio C HamanoNext: brian m. carlson
Message 6 of 8 in “freshen_file(): use NULL `times' for implicit current-time”
  1. 1/1 freshen_file(): use NULL `times' for implicit current-timeluciano.rocha@booking.com, Apr 14, 2020
  2. Jeff KingApr 14, 2020
  3. luciano.rocha@booking.comApr 15, 2020
  4. Jeff KingApr 15, 2020
  5. Junio C HamanoApr 15, 2020
  6. Junio C HamanoApr 15, 2020
  7. brian m. carlsonApr 15, 2020
  8. Junio C HamanoApr 16, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.