]> git.ipfire.org Git - thirdparty/git.git/commitdiff
partial-clone: add a partial-clone test case
authorAbhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
Wed, 16 Mar 2022 09:46:09 +0000 (09:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2022 18:11:07 +0000 (11:11 -0700)
In a blobless-cloned repo, `git log --follow -- <path>` (`<path>` have
an exact OID rename) shouldn't download blob of the file from where the
new file is renamed.

Add a test case to verify it.

Signed-off-by: Abhradeep Chakraborty <chakrabortyabhradeep79@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0410-partial-clone.sh

index f17abd298c83467b3ead07ff87c08623ff640502..1e864cf3172bec45e949a840d026e507a117fec8 100755 (executable)
@@ -618,6 +618,25 @@ test_expect_success 'do not fetch when checking existence of tree we construct o
        git -C repo cherry-pick side1
 '
 
+test_expect_success 'exact rename does not need to fetch the blob lazily' '
+       rm -rf repo partial.git &&
+       test_create_repo repo &&
+       content="some dummy content" &&
+       test_commit -C repo create-a-file file.txt "$content" &&
+       git -C repo mv file.txt new-file.txt &&
+       git -C repo commit -m rename-the-file &&
+       FILE_HASH=$(git -C repo rev-parse HEAD:new-file.txt) &&
+       test_config -C repo uploadpack.allowfilter 1 &&
+       test_config -C repo uploadpack.allowanysha1inwant 1 &&
+
+       git clone --filter=blob:none --bare "file://$(pwd)/repo" partial.git &&
+       git -C partial.git rev-list --objects --missing=print HEAD >out &&
+       grep "[?]$FILE_HASH" out &&
+       git -C partial.git log --follow -- new-file.txt &&
+       git -C partial.git rev-list --objects --missing=print HEAD >out &&
+       grep "[?]$FILE_HASH" out
+'
+
 test_expect_success 'lazy-fetch when accessing object not in the_repository' '
        rm -rf full partial.git &&
        test_create_repo full &&