]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5550-http-fetch-dumb.sh
http-fetch: support fetching packfiles by URL
[thirdparty/git.git] / t / t5550-http-fetch-dumb.sh
index 50485300eb19ea757dac4ee36ec395329d33e1f0..ca2e8af022f0b4749fd4fcd30de93864c780f04a 100755 (executable)
@@ -199,6 +199,28 @@ test_expect_success 'fetch packed objects' '
        git clone $HTTPD_URL/dumb/repo_pack.git
 '
 
+test_expect_success 'http-fetch --packfile' '
+       # Arbitrary hash. Use rev-parse so that we get one of the correct
+       # length.
+       ARBITRARY=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
+
+       git init packfileclient &&
+       p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && ls objects/pack/pack-*.pack) &&
+       git -C packfileclient http-fetch --packfile=$ARBITRARY "$HTTPD_URL"/dumb/repo_pack.git/$p >out &&
+
+       grep "^keep.[0-9a-f]\{16,\}$" out &&
+       cut -c6- out >packhash &&
+
+       # Ensure that the expected files are generated
+       test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).pack" &&
+       test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).idx" &&
+       test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).keep" &&
+
+       # Ensure that it has the HEAD of repo_pack, at least
+       HASH=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
+       git -C packfileclient cat-file -e "$HASH"
+'
+
 test_expect_success 'fetch notices corrupt pack' '
        cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
@@ -214,6 +236,14 @@ test_expect_success 'fetch notices corrupt pack' '
        )
 '
 
+test_expect_success 'http-fetch --packfile with corrupt pack' '
+       rm -rf packfileclient &&
+       git init packfileclient &&
+       p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git && ls objects/pack/pack-*.pack) &&
+       test_must_fail git -C packfileclient http-fetch --packfile \
+               "$HTTPD_URL"/dumb/repo_bad1.git/$p
+'
+
 test_expect_success 'fetch notices corrupt idx' '
        cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&