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

[PATCH] send-pack: respect '+' on wildcard refspecs

From
Jeff King <peff@peff.net>
Date
Oct 19, 2007, 09:04 UTC
Message-ID
<20071019090400.GA8944@coredump.intra.peff.net>

When matching source and destination refs, we were failing to pull the 'force' parameter from wildcard respects (but not explicit ones) and attach it to the ref struct.

This adds a test for explicit and wildcard refspecs; the latter fails without this patch.

Signed-off-by: Jeff King <peff@peff.net>
---
 remote.c             |    2 ++
 t/t5400-send-pack.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/remote.c b/remote.c
index b20e2be..170015a 100644
--- a/remote.c
+++ b/remote.c
@@ -762,6 +762,8 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
 			hashcpy(dst_peer->new_sha1, src->new_sha1);
 		}
 		dst_peer->peer_ref = src;
+		if (pat)
+			dst_peer->force = pat->force;
 	free_name:
 		free(dst_name);
 	}
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 57c6397..2d0c07f 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -123,4 +123,52 @@ test_expect_success \
 	git-branch -a >branches && ! grep -q origin/master branches
 '
 
+rewound_push_setup() {
+	rm -rf parent child &&
+	mkdir parent && cd parent &&
+	git-init && echo one >file && git-add file && git-commit -m one &&
+	echo two >file && git-commit -a -m two &&
+	cd .. &&
+	git-clone parent child && cd child && git-reset --hard HEAD^
+}
+
+rewound_push_succeeded() {
+	cmp ../parent/.git/refs/heads/master .git/refs/heads/master
+}
+
+rewound_push_failed() {
+	if rewound_push_succeeded
+	then
+		false
+	else
+		true
+	fi
+}
+
+test_expect_success \
+	'pushing explicit refspecs respects forcing' '
+	rewound_push_setup &&
+	if git-send-pack ../parent/.git refs/heads/master:refs/heads/master
+	then
+		false
+	else
+		true
+	fi && rewound_push_failed &&
+	git-send-pack ../parent/.git +refs/heads/master:refs/heads/master &&
+	rewound_push_succeeded
+'
+
+test_expect_success \
+	'pushing wildcard refspecs respects forcing' '
+	rewound_push_setup &&
+	if git-send-pack ../parent/.git refs/heads/*:refs/heads/*
+	then
+		false
+	else
+		true
+	fi && rewound_push_failed &&
+	git-send-pack ../parent/.git +refs/heads/*:refs/heads/* &&
+	rewound_push_succeeded
+'
+
 test_done
-- 
1.5.3.4.1254.gc1ca9-dirty
Next: Jeff King
Message 1 of 10 in “send-pack: respect '+' on wildcard refspecs”
  1. send-pack: respect '+' on wildcard refspecsJeff King, Oct 19, 2007
  2. Jeff KingOct 19, 2007
  3. Dan McGeeOct 19, 2007
  4. Jeff KingOct 19, 2007
  5. Dan McGeeOct 19, 2007
  6. Jeff KingOct 19, 2007
  7. Dan McGeeOct 19, 2007
  8. Dan McGeeOct 20, 2007
  9. Jeff KingOct 20, 2007
  10. Shawn O. PearceOct 20, 2007

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.