git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t5551: test fetch.c:backfill_tags() code
@ 2013-12-05  3:34 Nguyễn Thái Ngọc Duy
  0 siblings, 0 replies; only message in thread
From: Nguyễn Thái Ngọc Duy @ 2013-12-05  3:34 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

This makes sure the second fetch with transport helper code path is
exercised in the test suite.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 This should catch the problem by aa/transport-non-positive-depth-only.
 The GIT_TEST_BACKFILL_TAGS is bad but I don't know any sure way to
 verify it, assuming the shallow code may change in future and stop
 triggering backfill_tags().

 builtin/fetch.c       |  2 ++
 t/t5551-http-fetch.sh | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5647055..2496ad2 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -750,6 +750,8 @@ static struct transport *prepare_transport(struct remote *remote)
 
 static void backfill_tags(struct transport *transport, struct ref *ref_map)
 {
+	if (getenv("GIT_TEST_BACKFILL_TAGS"))
+		fprintf(stderr, "backfill_tags executed\n");
 	if (transport->cannot_reuse) {
 		gsecondary = prepare_transport(transport->remote);
 		transport = gsecondary;
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index 1b71bb5..7eeb043 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -181,6 +181,22 @@ test_expect_success 'create namespaced refs' '
 		symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master
 '
 
+test_expect_success 'trigger backfill_tags() over smart-http' '
+	git tag -m two tag-two &&
+	echo content >>file &&
+	git commit -a -m three &&
+	git push public master tag-two &&
+	git rev-parse master tag-two >expected &&
+	(
+	git init shallow &&
+	cd shallow &&
+	GIT_TEST_BACKFILL_TAGS=1 git fetch --depth=2 $HTTPD_URL/smart/repo.git master:foo 2>err &&
+	grep "backfill_tags executed" err &&
+	git rev-parse foo tag-two >../actual
+	) &&
+	test_cmp expected actual
+'
+
 test_expect_success 'smart clone respects namespace' '
 	git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart &&
 	echo namespaced >expect &&
-- 
1.8.5.1.25.g8667982

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-05  3:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05  3:34 [PATCH] t5551: test fetch.c:backfill_tags() code Nguyễn Thái Ngọc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).