Skip to content

Commit ce4cb07

Browse files
committed
tests: verify renaming branch really updates worktree HEAD
In case where a branch is getting renamed, all HEADs of the main repository and of its worktrees that point to the old branch need to get updated to point to the new branch. We already do so and have a test for this, but the test only verifies that we're able to lookup the updated HEAD, not what it contains. Let's make the test more specific by verifying the updated HEAD also has the correct updated symbolic target.
1 parent 5434f9a commit ce4cb07

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/worktree/refs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ void test_worktree_refs__renaming_reference_updates_worktree_heads(void)
163163
cl_git_pass(git_branch_lookup(&branch, fixture.repo,
164164
"testrepo-worktree", GIT_BRANCH_LOCAL));
165165
cl_git_pass(git_reference_rename(&renamed, branch, "refs/heads/renamed", 0, NULL));
166-
cl_git_pass(git_repository_head(&head, fixture.worktree));
166+
167+
cl_git_pass(git_reference_lookup(&head, fixture.worktree, GIT_HEAD_FILE));
168+
cl_assert_equal_i(git_reference_type(head), GIT_REFERENCE_SYMBOLIC);
169+
cl_assert_equal_s(git_reference_symbolic_target(head), "refs/heads/renamed");
167170

168171
git_reference_free(head);
169172
git_reference_free(branch);

0 commit comments

Comments
 (0)