Commit e89289c
committed
rebase: skip branch symref aliases
git rebase --update-refs can finish rewriting the current branch and
then fail while updating a local branch that is a symbolic ref. This can
happen during a default-branch rename where refs/heads/main points at
refs/heads/master while users migrate.
Fix this because the post-rebase failure leaves refs partially updated
even though the main rebase has succeeded.
The sequencer queues updates from local branch decorations. Commit
106b688 (rebase: ignore non-branch update-refs) filters out
decorations that are not local branches, such as HEAD and tags. A branch
symref is still a local branch decoration, but refs_update_ref()
dereferences it. A symref to another branch therefore duplicates the
concrete branch update. Multiple aliases to the same non-branch ref can
likewise queue duplicate updates, causing the second compare-and-swap to
fail.
Resolve each local branch decoration before queuing it. Skip symrefs
whose referents are under refs/heads/, since the concrete branch
decoration already represents that update. Keep an owned copy of the
resolved HEAD and skip the current branch before checked-out handling so
later ref resolution cannot change the comparison.
For symrefs to non-branch targets, check both the literal alias and its
resolved referent against checked-out reservations. Deduplicate queued
updates by referent so multiple aliases cannot update the same ref
twice. When loading another worktree's update-refs state, reserve both
the literal symref and its resolved target so different aliases honor
the same in-progress update.
Cover branch aliases, current-branch handling, checked-out non-branch
targets, duplicate non-branch aliases, and cross-worktree reservations.
Signed-off-by: Son Luong Ngoc <sluongng@gmail.com>1 parent 48bbf81 commit e89289c
4 files changed
Lines changed: 155 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
445 | 448 | | |
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
449 | 464 | | |
450 | 465 | | |
451 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6459 | 6459 | | |
6460 | 6460 | | |
6461 | 6461 | | |
| 6462 | + | |
6462 | 6463 | | |
6463 | 6464 | | |
6464 | 6465 | | |
6465 | 6466 | | |
6466 | 6467 | | |
6467 | 6468 | | |
6468 | | - | |
6469 | | - | |
6470 | | - | |
6471 | | - | |
6472 | | - | |
| 6469 | + | |
| 6470 | + | |
| 6471 | + | |
| 6472 | + | |
6473 | 6473 | | |
6474 | 6474 | | |
6475 | 6475 | | |
6476 | 6476 | | |
| 6477 | + | |
| 6478 | + | |
| 6479 | + | |
6477 | 6480 | | |
6478 | 6481 | | |
6479 | 6482 | | |
6480 | | - | |
6481 | | - | |
6482 | | - | |
6483 | | - | |
6484 | 6483 | | |
6485 | 6484 | | |
6486 | 6485 | | |
6487 | 6486 | | |
6488 | | - | |
6489 | | - | |
| 6487 | + | |
| 6488 | + | |
| 6489 | + | |
| 6490 | + | |
| 6491 | + | |
| 6492 | + | |
| 6493 | + | |
| 6494 | + | |
| 6495 | + | |
| 6496 | + | |
| 6497 | + | |
| 6498 | + | |
| 6499 | + | |
| 6500 | + | |
| 6501 | + | |
| 6502 | + | |
| 6503 | + | |
| 6504 | + | |
| 6505 | + | |
| 6506 | + | |
| 6507 | + | |
| 6508 | + | |
| 6509 | + | |
| 6510 | + | |
| 6511 | + | |
| 6512 | + | |
| 6513 | + | |
| 6514 | + | |
| 6515 | + | |
| 6516 | + | |
| 6517 | + | |
| 6518 | + | |
| 6519 | + | |
| 6520 | + | |
6490 | 6521 | | |
6491 | 6522 | | |
6492 | 6523 | | |
| |||
6498 | 6529 | | |
6499 | 6530 | | |
6500 | 6531 | | |
6501 | | - | |
| 6532 | + | |
6502 | 6533 | | |
6503 | 6534 | | |
6504 | 6535 | | |
6505 | 6536 | | |
6506 | 6537 | | |
6507 | 6538 | | |
| 6539 | + | |
| 6540 | + | |
| 6541 | + | |
| 6542 | + | |
6508 | 6543 | | |
6509 | 6544 | | |
6510 | 6545 | | |
| |||
6518 | 6553 | | |
6519 | 6554 | | |
6520 | 6555 | | |
| 6556 | + | |
6521 | 6557 | | |
6522 | 6558 | | |
6523 | 6559 | | |
| 6560 | + | |
6524 | 6561 | | |
6525 | 6562 | | |
6526 | 6563 | | |
| |||
6534 | 6571 | | |
6535 | 6572 | | |
6536 | 6573 | | |
| 6574 | + | |
6537 | 6575 | | |
6538 | 6576 | | |
6539 | 6577 | | |
| |||
6559 | 6597 | | |
6560 | 6598 | | |
6561 | 6599 | | |
| 6600 | + | |
6562 | 6601 | | |
6563 | 6602 | | |
6564 | 6603 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1975 | 1975 | | |
1976 | 1976 | | |
1977 | 1977 | | |
| 1978 | + | |
1978 | 1979 | | |
1979 | 1980 | | |
1980 | 1981 | | |
1981 | 1982 | | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1982 | 1987 | | |
1983 | 1988 | | |
1984 | 1989 | | |
1985 | 1990 | | |
1986 | 1991 | | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
1987 | 1995 | | |
1988 | 1996 | | |
1989 | 1997 | | |
1990 | 1998 | | |
1991 | 1999 | | |
1992 | 2000 | | |
1993 | 2001 | | |
| 2002 | + | |
1994 | 2003 | | |
1995 | 2004 | | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
1996 | 2012 | | |
1997 | 2013 | | |
1998 | 2014 | | |
| |||
2008 | 2024 | | |
2009 | 2025 | | |
2010 | 2026 | | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2011 | 2099 | | |
2012 | 2100 | | |
2013 | 2101 | | |
| |||
0 commit comments