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

Re: [PATCH v3] set-head: no update without change and better output for --auto

From
Bence Ferdinandy <bence@ferdinandy.com>
Date
Sep 17, 2024, 20:32 UTC
Message-ID
<D48UGAZA205N.37QFSURUDN3ZS@ferdinandy.com>
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
Previous: Bence FerdinandyNext: Junio C Hamano
Message 4 of 6 in “set-head: no update without change and better output for --auto”
  1. set-head: no update without change and better output for --autoBence Ferdinandy, Sep 15, 2024
  2. Junio C HamanoSep 16, 2024
  3. Bence FerdinandySep 16, 2024
  4. Bence FerdinandySep 17, 2024
  5. Junio C HamanoSep 17, 2024
  6. Bence FerdinandySep 19, 2024

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.