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

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

From
Jacob Keller <jacob.keller@gmail.com>
Date
Jun 17, 2022, 00:20 UTC
Message-ID
<20220617002036.1577-7-jacob.keller@gmail.com>
In-Reply-To
<20220617002036.1577-1-jacob.keller@gmail.com>

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 --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 &&
-- 
2.36.1
Previous: Jacob KellerNext: Jacob Keller
Message 6 of 7 in “remote: handle negative refspecs with show”
  1. 0/6 remote: handle negative refspecs with showJacob Keller, Jun 17, 2022
  2. 1/6 remote: handle negative refspecs in git remote showJacob Keller, Jun 17, 2022
  3. 3/6 tests: handle --global directly in test_config/test_unconfigJacob Keller, Jun 17, 2022
  4. 2/6 t5505: remove sub shell use in favor of git -CJacob Keller, Jun 17, 2022
  5. 4/6 tests: only automatically unset matching values from test_configJacob Keller, Jun 17, 2022
  6. 6/6 remote: add test for negative refspec with pruneJacob Keller, Jun 17, 2022
  7. 5/6 t5505: use test_config where appropriateJacob Keller, Jun 17, 2022

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.