]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/no-clobber-dangling-symref-with-fetch'
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 Aug 2025 16:44:37 +0000 (09:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Aug 2025 16:44:37 +0000 (09:44 -0700)
"git fetch" can clobber a symref that is dangling when the
remote-tracking HEAD is set to auto update, which has been
corrected.

* jk/no-clobber-dangling-symref-with-fetch:
  refs: do not clobber dangling symrefs
  t5510: prefer "git -C" to subshell for followRemoteHEAD tests
  t5510: stop changing top-level working directory
  t5510: make confusing config cleanup more explicit

1  2 
refs/files-backend.c
refs/reftable-backend.c
t/t1400-update-ref.sh

Simple merge
Simple merge
index 96648a6e5dfd89cc31f2c75654dd831c39ad5611,29b31e3b9bda80b2dbd7444c7b2bf6fe1c06104a..b7415ec9d5a4861c48db84172ab83d39b92e862c
@@@ -2349,23 -2310,25 +2349,44 @@@ test_expect_success 'update-ref should 
        test_cmp expect actual
  '
  
 +test_expect_success REFFILES 'empty directories are pruned when aborting a transaction' '
 +      test_path_is_missing .git/refs/heads/nested &&
 +      git update-ref --stdin <<-EOF &&
 +      create refs/heads/nested/something HEAD
 +      prepare
 +      abort
 +      EOF
 +      test_path_is_missing .git/refs/heads/nested
 +'
 +
 +test_expect_success REFFILES 'empty directories are pruned when not committing' '
 +      test_path_is_missing .git/refs/heads/nested &&
 +      git update-ref --stdin <<-EOF &&
 +      create refs/heads/nested/something HEAD
 +      prepare
 +      EOF
 +      test_path_is_missing .git/refs/heads/nested
 +'
 +
+ test_expect_success 'dangling symref not overwritten by creation' '
+       test_when_finished "git update-ref -d refs/heads/dangling" &&
+       git symbolic-ref refs/heads/dangling refs/heads/does-not-exist &&
+       test_must_fail git update-ref --no-deref --stdin 2>err <<-\EOF &&
+       create refs/heads/dangling HEAD
+       EOF
+       test_grep "cannot lock.*dangling symref already exists" err &&
+       test_must_fail git rev-parse --verify refs/heads/dangling &&
+       test_must_fail git rev-parse --verify refs/heads/does-not-exist
+ '
+ test_expect_success 'dangling symref overwritten without old oid' '
+       test_when_finished "git update-ref -d refs/heads/dangling" &&
+       git symbolic-ref refs/heads/dangling refs/heads/does-not-exist &&
+       git update-ref --no-deref --stdin <<-\EOF &&
+       update refs/heads/dangling HEAD
+       EOF
+       git rev-parse --verify refs/heads/dangling &&
+       test_must_fail git rev-parse --verify refs/heads/does-not-exist
+ '
  test_done