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