git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: luciano.rocha@booking.com
Cc: git@vger.kernel.org, peff@peff.net
Subject: Re: [PATCH 1/1] freshen_file(): use NULL `times' for implicit current-time
Date: Wed, 15 Apr 2020 14:36:14 -0700	[thread overview]
Message-ID: <xmqq4ktk5t4h.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <5e95d37d.1c69fb81.2b4ec.ce9f@mx.google.com> (luciano rocha's message of "Tue, 14 Apr 2020 16:27:26 +0200")

luciano.rocha@booking.com writes:

> 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.

> 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);
>  }
>  
>  /*

  parent reply	other threads:[~2020-04-15 21:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-04-15 23:48   ` brian m. carlson
2020-04-16  1:02     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4ktk5t4h.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=luciano.rocha@booking.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).