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

Push force-with-lease with multi-URL remote

From
CHChristopher Head <bugs@chead.ca>
Date
Jul 27, 2019, 16:54 UTC
Message-ID
<20190727095440.1aac3b3c@amdahl.home.chead.ca>

Hi folks, When a single remote has multiple push URLs, Git’s force-with-lease logic appears to be:

For each URL:
1. Read refs/heads/mybranch (call this commit X)
2. Read refs/remotes/myremote/mybranch (call this commit Y)
3. Send to the URL an atomic compare-and-swap, replacing Y with X.
4. If step 3 succeeded, change refs/remotes/myremote/mybranch to X.

This means that, assuming both URLs start out identical, the second URL will always fail because refs/remots/myremote/mybranch has been updated from Y to X, and therefore the second compare-and-swap fails. I can’t imagine any situation in which this behaviour is actually useful.

This is what I would expect:
1. Read refs/heads/mybranch (call this commit X)
2. Read refs/remotes/myremote/mybranch (call this commit Y)
3. For each URL:
3a. Send to the URL an atomic compare-and-swap, replacing Y with X.
4. If any (or maybe all) of the CAS operations in 3a succeeded, change
refs/remotes/myremote/mybranch to X.

Thoughts? Does anyone have a use case for the existing behaviour? I have attached a shell script which constructs some repos and demonstrates the situation.

Thanks!
-- 
Christopher Head
Next: Junio C Hamano
Message 1 of 12 in “Push force-with-lease with multi-URL remote”
  1. Christopher HeadJul 27, 2019
  2. Junio C HamanoJul 27, 2019
  3. Christopher HeadJul 27, 2019
  4. Junio C HamanoJul 27, 2019
  5. Christopher HeadJul 27, 2019
  6. Junio C HamanoJul 29, 2019
  7. Jeff KingJul 29, 2019
  8. Junio C HamanoJul 29, 2019
  9. Christopher HeadJul 29, 2019
  10. Jeff KingJul 29, 2019
  11. Junio C HamanoJul 29, 2019
  12. Jeff KingJul 29, 2019

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.