diff mbox series

[v2] t3200: refactor symlink test from hn/refs-errno-cleanup

Message ID 20210819075244.36776-1-carenas@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] t3200: refactor symlink test from hn/refs-errno-cleanup | expand

Commit Message

Carlo Marcelo Arenas Belón Aug. 19, 2021, 7:52 a.m. UTC
d1931bcf0d (refs: make errno output explicit for refs_resolve_ref_unsafe,
2021-07-20) add a test for a crash when refs is a symlink, but it fails
on windows.

add the missing SYMLINKS dependency and while at it, refactor it slightly
to comply better with the CodingGuidelines.

Reported-by: Jeff King <peff@peff.net>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
v2:
* update subject for clarity; might be worth squashing instead into 3d63ce75e
  (refs: explicitly return failure_errno from parse_loose_ref_contents,
  2021-07-20)
* change from --git-dir to -C for clarity
* add reporting for errors to the for loop as suggested by Eric

 t/t3200-branch.sh | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)


base-commit: d1931bcf0d5ef75cdaf836347f4aefce902a6a38

Comments

Junio C Hamano Aug. 19, 2021, 8:26 p.m. UTC | #1
Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:

> d1931bcf0d (refs: make errno output explicit for refs_resolve_ref_unsafe,
> 2021-07-20) add a test for a crash when refs is a symlink, but it fails
> on windows.
>
> add the missing SYMLINKS dependency and while at it, refactor it slightly
> to comply better with the CodingGuidelines.
>
> Reported-by: Jeff King <peff@peff.net>
> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> v2:
> * update subject for clarity; might be worth squashing instead into 3d63ce75e
>   (refs: explicitly return failure_errno from parse_loose_ref_contents,
>   2021-07-20)
> * change from --git-dir to -C for clarity
> * add reporting for errors to the for loop as suggested by Eric

Thanks for a fix-up.

Let's eject hn/refs-errno-cleanup and possibly ab/refs-files-cleanup
topics out of 'next' and give these 18 patches a chance for a fresh
start, as I've already failed a short-cut attempt to squash in the
"fix" yesterday that forgot the SYMLINKS prerequisite and even
today's attempts to fix it seem to be going back and forth X-<.
Even worse, there is a t0031 breakage that seems to have come from
the latter topic.

IOW, I won't be picking this up but asking Han-Wen and Ævar to come
up with a clean reroll of the two series.

Thanks.
Junio C Hamano Aug. 19, 2021, 8:26 p.m. UTC | #2
Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:

> d1931bcf0d (refs: make errno output explicit for refs_resolve_ref_unsafe,
> 2021-07-20) add a test for a crash when refs is a symlink, but it fails
> on windows.
>
> add the missing SYMLINKS dependency and while at it, refactor it slightly
> to comply better with the CodingGuidelines.
>
> Reported-by: Jeff King <peff@peff.net>
> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> v2:
> * update subject for clarity; might be worth squashing instead into 3d63ce75e
>   (refs: explicitly return failure_errno from parse_loose_ref_contents,
>   2021-07-20)
> * change from --git-dir to -C for clarity
> * add reporting for errors to the for loop as suggested by Eric

Thanks for a fix-up.

Let's eject hn/refs-errno-cleanup and possibly ab/refs-files-cleanup
topics out of 'next' and give these 18 patches a chance for a fresh
start, as I've already failed a short-cut attempt to squash in the
"fix" yesterday that forgot the SYMLINKS prerequisite and even
today's attempts to fix it seem to be going back and forth X-<.
Even worse, there is a t0031 breakage that seems to have come from
the latter topic.

IOW, I won't be picking this up but asking Han-Wen and Ævar to come
up with a clean reroll of the two series, using this as an input
(perhaps Helped-by: etc. would be needed).

Thanks.
diff mbox series

Patch

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index dd17718160..eacb6bcd35 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -109,17 +109,22 @@  test_expect_success 'git branch -m n/n n should work' '
 	git reflog exists refs/heads/n
 '
 
-test_expect_success 'git branch -m with symlinked .git/refs' '
+test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
 	git init subdir &&
 	test_when_finished "rm -rf subdir" &&
-	(cd subdir &&
-		for d in refs objects packed-refs ; do
-		rm -rf .git/$d &&
-		ln -s ../../.git/$d .git/$d ; done ) &&
-	git --git-dir subdir/.git/ branch rename-src &&
-	expect=$(git rev-parse rename-src) &&
-	git --git-dir subdir/.git/ branch -m rename-src rename-dest &&
-	test $(git rev-parse rename-dest) = "$expect" &&
+	(
+		cd subdir &&
+		for d in refs objects packed-refs
+		do
+			rm -rf .git/$d &&
+			ln -s ../../.git/$d .git/$d || exit 1
+		done
+	) &&
+	git -C subdir branch rename-src &&
+	git rev-parse rename-src >expect &&
+	git -C subdir branch -m rename-src rename-dest &&
+	git rev-parse rename-dest >actual &&
+	test_cmp expect actual &&
 	git branch -D rename-dest
 '