This fixes a bug I found while investigating another semi-related bug (that has already been fixed by Patrick), mentioned in the "PS" here: https://lore.kernel.org/git/20250724104536.GA1316505@xxxxxxxxxxxxxxxxxxxxxxx/ The issue is that: git remote add -m does-not-exist origin <url> git config remote.origin.followRemoteHEAD create git fetch will overwrite the refs/remotes/origin/HEAD we created, even though we asked it to do so only on creation. The issue is actually in the refs code, and how it perceives dangling symrefs with respect to creation events. And so this actually affects "update-ref", as well. A fix is in the final patch, along with a detailed explanation. The earlier patches are just cleanup of the related test script before we add our new test there. [1/4]: t5510: make confusing config cleanup more explicit [2/4]: t5510: stop changing top-level working directory [3/4]: t5510: prefer "git -C" to subshell for followRemoteHEAD tests [4/4]: refs: do not clobber dangling symrefs refs/files-backend.c | 34 ++- refs/reftable-backend.c | 30 ++- t/t1400-update-ref.sh | 21 ++ t/t5510-fetch.sh | 543 ++++++++++++++++++---------------------- 4 files changed, 319 insertions(+), 309 deletions(-) -Peff