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

[PATCH v3 4/5] worktree: add test for path handling in linked worktrees

From
Caleb White <cdwhite3@pm.me>
Date
Oct 25, 2024, 20:57 UTC
Message-ID
<20241025-wt_relative_paths-v3-4-8860a5321c01@pm.me>
In-Reply-To
<20241025-wt_relative_paths-v3-0-8860a5321c01@pm.me>

A failure scenario reported in an earlier patch series[1] that several `git worktree` subcommands failed or misbehaved when invoked from within linked worktrees that used relative paths.

This adds a test that executes a `worktree prune` command inside both an internally and an externally linked worktree and asserts that the other worktree was not pruned.

[1]: https://lore.kernel.org/git/CAPig+cQXFy=xPVpoSq6Wq0pxMRCjS=WbkgdO+3LySPX=q0nPCw@mail.gmail.com/
Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Caleb White <cdwhite3@pm.me>
---
 t/t2401-worktree-prune.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh
index 71aa9bcd620f8a504fe628a2d7332d8b47fd4701..5eb52b9abbf29514dc082c260ebb7a5e8e63aae0 100755
--- a/t/t2401-worktree-prune.sh
+++ b/t/t2401-worktree-prune.sh
@@ -120,4 +120,24 @@ test_expect_success 'prune duplicate (main/linked)' '
 	! test -d .git/worktrees/wt
 '
 
+test_expect_success 'not prune proper worktrees inside linked worktree with relative paths' '
+	test_when_finished rm -rf repo wt_ext &&
+	git init repo &&
+	(
+	    cd repo &&
+	    git config worktree.useRelativePaths true &&
+	    echo content >file &&
+	    git add file &&
+	    git commit -m msg &&
+	    git worktree add ../wt_ext &&
+	    git worktree add wt_int &&
+	    cd wt_int &&
+	    git worktree prune -v >out &&
+	    test_must_be_empty out &&
+	    cd ../../wt_ext &&
+	    git worktree prune -v >out &&
+	    test_must_be_empty out
+	)
+'
+
 test_done
-- 
2.47.0
Previous: Caleb WhiteNext: Caleb White
Message 4 of 11 in “Optionally link worktrees with relative paths”
  1. 0/5 Optionally link worktrees with relative pathsCaleb White, Oct 25, 2024
  2. 1/5 worktree: refactor infer_backlink() to use strbuf*Caleb White, Oct 25, 2024
  3. 2/5 worktree: support worktrees linked with relative pathsCaleb White, Oct 25, 2024
  4. 4/5 worktree: add test for path handling in linked worktreesCaleb White, Oct 25, 2024
  5. 3/5 worktree: optionally link worktrees with relative pathsCaleb White, Oct 25, 2024
  6. 5/5 worktree: add `relativeWorktrees` extensionCaleb White, Oct 25, 2024
  7. Caleb WhiteOct 25, 2024
  8. Taylor BlauOct 25, 2024
  9. Caleb WhiteOct 25, 2024
  10. Taylor BlauOct 25, 2024
  11. Caleb WhiteOct 25, 2024

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.