On Mon Sep 16, 2024 at 20:36, Junio C Hamano <gitster@xxxxxxxxx> 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