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

[PATCH v2 1/2] t1415: avoid using `main` as ref name

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 8, 2020, 10:13 UTC
Message-ID
<2c6f41f9adf361dd700fefaf0fa7819720929c04.1602152027.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.743.v2.git.1602152027.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In preparation for a patch series that will change the fall-back for `init.defaultBranch` to `main`, let's not use `main` as ref name in this test script.

Otherwise, the `git for-each-ref ... | grep main` which wants to catch those refs would also unexpectedly catch `refs/heads/main`.

Since the refs in question are worktree-local ones (i.e. each worktree has their own, just like `HEAD`), and since the test case already uses a secondary worktree called "second", let's use the name "first" for those refs instead.

While at it, adjust the test titles that talk about a "repo" when they meant a "worktree" instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t1415-worktree-refs.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/t/t1415-worktree-refs.sh b/t/t1415-worktree-refs.sh
index bb2c7572a3..7ab91241ab 100755
--- a/t/t1415-worktree-refs.sh
+++ b/t/t1415-worktree-refs.sh
@@ -76,24 +76,24 @@ test_expect_success 'reflog of worktrees/xx/HEAD' '
 	test_cmp expected actual.wt2
 '
 
-test_expect_success 'for-each-ref from main repo' '
+test_expect_success 'for-each-ref from main worktree' '
 	mkdir fer1 &&
 	git -C fer1 init repo &&
 	test_commit -C fer1/repo initial &&
 	git -C fer1/repo worktree add ../second &&
-	git -C fer1/repo update-ref refs/bisect/main HEAD &&
-	git -C fer1/repo update-ref refs/rewritten/main HEAD &&
-	git -C fer1/repo update-ref refs/worktree/main HEAD &&
-	git -C fer1/repo for-each-ref --format="%(refname)" | grep main >actual &&
+	git -C fer1/repo update-ref refs/bisect/first HEAD &&
+	git -C fer1/repo update-ref refs/rewritten/first HEAD &&
+	git -C fer1/repo update-ref refs/worktree/first HEAD &&
+	git -C fer1/repo for-each-ref --format="%(refname)" | grep first >actual &&
 	cat >expected <<-\EOF &&
-	refs/bisect/main
-	refs/rewritten/main
-	refs/worktree/main
+	refs/bisect/first
+	refs/rewritten/first
+	refs/worktree/first
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'for-each-ref from linked repo' '
+test_expect_success 'for-each-ref from linked worktree' '
 	mkdir fer2 &&
 	git -C fer2 init repo &&
 	test_commit -C fer2/repo initial &&
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 10 of 11 in “Avoid main as branch name in the test suite”
  1. 0/2 Avoid main as branch name in the test suiteJohannes Schindelin via GitGitGadget, Oct 5, 2020
  2. 1/2 t1415: avoid using `main` as ref nameJohannes Schindelin via GitGitGadget, Oct 5, 2020
  3. Jonathan NiederOct 5, 2020
  4. Johannes SchindelinOct 8, 2020
  5. 2/2 tests: avoid using the branch name `main`Johannes Schindelin via GitGitGadget, Oct 5, 2020
  6. Jonathan NiederOct 5, 2020
  7. Johannes SchindelinOct 8, 2020
  8. Derrick StoleeOct 8, 2020
  9. 0/2 Avoid main as branch name in the test suiteJohannes Schindelin via GitGitGadget, Oct 8, 2020
  10. 1/2 t1415: avoid using `main` as ref nameJohannes Schindelin via GitGitGadget, Oct 8, 2020
  11. 2/2 tests: avoid using the branch name `main`Johannes Schindelin via GitGitGadget, Oct 8, 2020

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.