diff mbox series

[v3,6/6] remote: add test for negative refspec with prune

Message ID 20220617002036.1577-7-jacob.keller@gmail.com (mailing list archive)
State New, archived
Headers show
Series remote: handle negative refspecs with show | expand

Commit Message

Jacob Keller June 17, 2022, 12:20 a.m. UTC
git remote prune does not handle negative refspecs properly. If a
negative refspec got added after a fetch, a user may expect that the
resulting refs that were previously fetched would now be considered
stale, and thus removed by git remote prune. Show that this isn't the
case with a new test case.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 t/t5505-remote.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 8cad753023ef..0810e7d8d0b7 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -399,6 +399,19 @@  test_expect_success 'prune --dry-run' '
 	test_cmp expect output
 '
 
+cat >expect <<EOF
+Pruning origin
+URL: $(pwd)/one
+ * [would prune] origin/side2
+EOF
+
+test_expect_failure 'prune --dry-run negative refspec' '
+	test_config -C test --add remote.origin.fetch ^refs/heads/side2 &&
+	git -C test remote prune --dry-run origin >output &&
+	git -C test rev-parse refs/remotes/origin/side2 &&
+	test_cmp expect output
+'
+
 test_expect_success 'add --mirror && prune' '
 	mkdir mirror &&
 	git -C mirror init --bare &&