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 <pclo...@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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to