git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] t5551: test fetch.c:backfill_tags() code
Date: Thu,  5 Dec 2013 10:34:00 +0700	[thread overview]
Message-ID: <1386214440-16560-1-git-send-email-pclouds@gmail.com> (raw)

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

                 reply	other threads:[~2013-12-05  3:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386214440-16560-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).