All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bence Ferdinandy" <bence@ferdinandy.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Patrick Steinhardt" <ps@pks.im>,
	"Christian Schlack" <christian@backhub.co>,
	"Jeff King" <peff@peff.net>
Subject: Re: [PATCH v3] set-head: no update without change and better output for --auto
Date: Tue, 17 Sep 2024 22:32:54 +0200	[thread overview]
Message-ID: <D48UGAZA205N.37QFSURUDN3ZS@ferdinandy.com> (raw)
In-Reply-To: <xmqq5xqvo37s.fsf@gitster.g>


On Mon Sep 16, 2024 at 20:36, Junio C Hamano <gitster@pobox.com> wrote:

[snip]

>  - This is inherently racy, isn't it?  We read the _current_ value.
>    After we do so, but before we write _our_ value, another process
>    may update it, so we'd end up overwriting the value they wrote.

So I've been thinking my first patch need not be so ambitious. The current
behaviour is to indiscriminately overwrite remote/HEAD. So what if we dial this
back a bit, leave the indiscriminate overwrite in place (the added benefit of
that is pretty small anyway) and only improve the printed output, which was the
main goal anyway? 

This is still slightly racy, since between the read and the write the status of
remote/HEAD could still change potentially, so the information received by the
user may be _slightly_ off, as we may be printing that the command just created
remote/HEAD when it was actually created a split millisecond earlier by another
command, but the printed end result will be always correct. And since the
output is aimed at humans really, I'd say even if some other process did create
that remote/HEAD between read and write, it's still actually true that before
running set-head it did not exist and now it does and is set to X.

In short: any raciness left should not have practical implications if we always
actually write remote/HEAD.

What do you think?

Best,
Bence

-- 
bence.ferdinandy.com


  parent reply	other threads:[~2024-09-17 20:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-15 22:09 [PATCH v3] set-head: no update without change and better output for --auto Bence Ferdinandy
2024-09-16 18:36 ` Junio C Hamano
2024-09-16 19:44   ` Bence Ferdinandy
2024-09-17 20:32   ` Bence Ferdinandy [this message]
2024-09-17 20:51     ` Junio C Hamano
2024-09-19 20:53       ` Bence Ferdinandy

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=D48UGAZA205N.37QFSURUDN3ZS@ferdinandy.com \
    --to=bence@ferdinandy.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=christian@backhub.co \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=szeder.dev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.