diff mbox series

[v2,09/11] t7064: use update-ref -d to remove upstream branch

Message ID 3685ba90f60ef95892a22c8549c9a3c0717d6662.1626989327.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Fix direct filesystem access in various test files. | expand

Commit Message

Han-Wen Nienhuys July 22, 2021, 9:28 p.m. UTC
From: Han-Wen Nienhuys <hanwen@google.com>

The previous code tested this by writing $ZERO_OID explicitly in the packed-refs
file. This is a type of corruption that doesn't reflect realistic use-cases. In
addition, even the ref-store test-tool refuses to write invalid OIDs.
(update-ref interprets $ZERO_OID is deleting the ref).

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 t/t7064-wtstatus-pv2.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Junio C Hamano July 23, 2021, 5:37 p.m. UTC | #1
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

>  		## Test upstream-gone case. Fake this by pointing
>  		## origin/initial-branch at a non-existing commit.
> -		OLD=$(git rev-parse origin/initial-branch) &&
> -		NEW=$ZERO_OID &&
> -		mv .git/packed-refs .git/old-packed-refs &&
> -		sed "s/$OLD/$NEW/g" <.git/old-packed-refs >.git/packed-refs &&
> +		git update-ref -d refs/remotes/origin/initial-branch &&

OK, so we now "fake" upstream-gone by making the upstream actually
gone ;-)  OK.

>  
>  		HUF=$(git rev-parse HEAD) &&
diff mbox series

Patch

diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh
index 4613882caff..eeb0534163d 100755
--- a/t/t7064-wtstatus-pv2.sh
+++ b/t/t7064-wtstatus-pv2.sh
@@ -373,10 +373,7 @@  test_expect_success 'verify upstream fields in branch header' '
 
 		## Test upstream-gone case. Fake this by pointing
 		## origin/initial-branch at a non-existing commit.
-		OLD=$(git rev-parse origin/initial-branch) &&
-		NEW=$ZERO_OID &&
-		mv .git/packed-refs .git/old-packed-refs &&
-		sed "s/$OLD/$NEW/g" <.git/old-packed-refs >.git/packed-refs &&
+		git update-ref -d refs/remotes/origin/initial-branch &&
 
 		HUF=$(git rev-parse HEAD) &&