| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test for no lazy fetch with the commit-graph' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup: prepare a repository with a commit' ' |
| 8 | git init with-commit && |
| 9 | test_commit -C with-commit the-commit && |
| 10 | oid=$(git -C with-commit rev-parse HEAD) |
| 11 | ' |
| 12 | |
| 13 | test_expect_success 'setup: prepare a repository with commit-graph contains the commit' ' |
| 14 | git init with-commit-graph && |
| 15 | echo "$(pwd)/with-commit/.git/objects" \ |
| 16 | >with-commit-graph/.git/objects/info/alternates && |
| 17 | # create a ref that points to the commit in alternates |
| 18 | git -C with-commit-graph update-ref refs/ref_to_the_commit "$oid" && |
| 19 | # prepare some other objects to commit-graph |
| 20 | test_commit -C with-commit-graph something && |
| 21 | git -c gc.writeCommitGraph=true -C with-commit-graph gc && |
| 22 | test_path_is_file with-commit-graph/.git/objects/info/commit-graph |
| 23 | ' |
| 24 | |
| 25 | test_expect_success 'setup: change the alternates to what without the commit' ' |
| 26 | git init --bare without-commit && |
| 27 | git -C with-commit-graph cat-file -e $oid && |
| 28 | echo "$(pwd)/without-commit/objects" \ |
| 29 | >with-commit-graph/.git/objects/info/alternates && |
| 30 | test_must_fail git -C with-commit-graph cat-file -e $oid |
| 31 | ' |
| 32 | |
| 33 | test_expect_success 'fetch any commit from promisor with the usage of the commit graph' ' |
| 34 | # setup promisor and prepare any commit to fetch |
| 35 | git -C with-commit-graph remote add origin "$(pwd)/with-commit" && |
| 36 | git -C with-commit-graph config remote.origin.promisor true && |
| 37 | git -C with-commit-graph config remote.origin.partialclonefilter blob:none && |
| 38 | test_commit -C with-commit any-commit && |
| 39 | anycommit=$(git -C with-commit rev-parse HEAD) && |
| 40 | test_must_fail env GIT_TRACE="$(pwd)/trace.txt" \ |
| 41 | git -C with-commit-graph fetch origin $anycommit 2>err && |
| 42 | test_grep ! "fatal: promisor-remote: unable to fork off fetch subprocess" err && |
| 43 | grep "git fetch origin" trace.txt >actual && |
| 44 | test_line_count = 1 actual |
| 45 | ' |
| 46 | |
| 47 | test_done |