git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Caleb White via B4 Relay <devnull+cdwhite3.pm.me@kernel.org>
To: git@vger.kernel.org
Cc: Caleb White <cdwhite3@pm.me>, Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v3 3/3] worktree: add test for path handling in linked worktrees
Date: Mon, 07 Oct 2024 22:12:32 -0500	[thread overview]
Message-ID: <20241007-wt_relative_paths-v3-3-622cf18c45eb@pm.me> (raw)
In-Reply-To: <20241007-wt_relative_paths-v3-0-622cf18c45eb@pm.me>

From: Caleb White <cdwhite3@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 | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh
index 71aa9bcd620f8a504fe628a2d7332d8b47fd4701..976d048e3efc74be9cd909ce76d552b3944d2e10 100755
--- a/t/t2401-worktree-prune.sh
+++ b/t/t2401-worktree-prune.sh
@@ -120,4 +120,23 @@ test_expect_success 'prune duplicate (main/linked)' '
 	! test -d .git/worktrees/wt
 '
 
+test_expect_success 'not prune proper worktrees when run inside linked worktree' '
+	test_when_finished rm -rf repo wt_ext &&
+	git init repo &&
+	(
+	    cd repo &&
+	    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.46.2



  parent reply	other threads:[~2024-10-08  3:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  3:12 [PATCH v3 0/3] Link worktrees with relative paths Caleb White via B4 Relay
2024-10-08  3:12 ` [PATCH v3 1/3] worktree: refactor infer_backlink() to use *strbuf Caleb White via B4 Relay
2024-10-10 15:52   ` shejialuo
2024-10-10 16:41     ` Caleb White
2024-10-10 17:26       ` shejialuo
2024-10-10 17:52         ` Caleb White
2024-10-10 20:03           ` Junio C Hamano
2024-10-10 20:24             ` Caleb White
2024-10-10 19:14       ` Junio C Hamano
2024-10-08  3:12 ` [PATCH v3 2/3] worktree: link worktrees with relative paths Caleb White via B4 Relay
2024-10-08 23:09   ` Junio C Hamano
2024-10-09 18:34     ` Caleb White
2024-10-09 19:10       ` Junio C Hamano
2024-10-09 19:19         ` Caleb White
2024-10-09 23:37           ` Junio C Hamano
2024-10-10 17:30             ` Caleb White
2024-10-11  4:03             ` Caleb White
2024-10-22  4:32             ` Caleb White
2024-10-09 10:11   ` Phillip Wood
2024-10-09 18:49     ` Caleb White
2024-10-08  3:12 ` Caleb White via B4 Relay [this message]
2024-10-08  4:48 ` [PATCH v3 0/3] Link " Caleb White
2024-10-08 19:00 ` Junio C Hamano
2024-10-08 21:55   ` Caleb White

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241007-wt_relative_paths-v3-3-622cf18c45eb@pm.me \
    --to=devnull+cdwhite3.pm.me@kernel.org \
    --cc=cdwhite3@pm.me \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).