1
+#!/bin/sh
2
+
3
+test_description='test for no lazy fetch with the commit-graph'
4
+
5
+. ./test-lib.sh
6
+
7
+run_with_limited_processses () {
8
+ # bash and ksh use "ulimit -u", dash uses "ulimit -p"
9
+ if test -n "$BASH_VERSION"
10
+ then
11
+ ulimit_max_process="-u"
12
+ elif test -n "$KSH_VERSION"
13
+ then
14
+ ulimit_max_process="-u"
15
+ fi
16
+ (ulimit ${ulimit_max_process-"-p"} 512 && "$@")
17
+}
18
+
19
+test_lazy_prereq ULIMIT_PROCESSES '
20
+ run_with_limited_processses true
21
+'
22
+
23
+if ! test_have_prereq ULIMIT_PROCESSES
24
+then
25
+ skip_all='skipping tests for no lazy fetch with the commit-graph, ulimit processes not available'
26
+ test_done
27
+fi
28
+
29
+test_expect_success 'setup: prepare a repository with a commit' '
30
+ git init with-commit &&
31
+ test_commit -C with-commit the-commit &&
32
+ oid=$(git -C with-commit rev-parse HEAD)
33
+'
34
+
35
+test_expect_success 'setup: prepare a repository with commit-graph contains the commit' '
36
+ git init with-commit-graph &&
37
+ echo "$(pwd)/with-commit/.git/objects" \
38
+ >with-commit-graph/.git/objects/info/alternates &&
39
+ # create a ref that points to the commit in alternates
40
+ git -C with-commit-graph update-ref refs/ref_to_the_commit "$oid" &&
41
+ # prepare some other objects to commit-graph
42
+ test_commit -C with-commit-graph something &&
43
+ git -c gc.writeCommitGraph=true -C with-commit-graph gc &&
44
+ test_path_is_file with-commit-graph/.git/objects/info/commit-graph
45
+'
46
+
47
+test_expect_success 'setup: change the alternates to what without the commit' '
48
+ git init --bare without-commit &&
49
+ git -C with-commit-graph cat-file -e $oid &&
50
+ echo "$(pwd)/without-commit/objects" \
51
+ >with-commit-graph/.git/objects/info/alternates &&
52
+ test_must_fail git -C with-commit-graph cat-file -e $oid
53
+'
54
+
55
+test_expect_success 'fetch any commit from promisor with the usage of the commit graph' '
56
+ # setup promisor and prepare any commit to fetch
57
+ git -C with-commit-graph remote add origin "$(pwd)/with-commit" &&
58
+ git -C with-commit-graph config remote.origin.promisor true &&
59
+ git -C with-commit-graph config remote.origin.partialclonefilter blob:none &&
60
+ test_commit -C with-commit any-commit &&
61
+ anycommit=$(git -C with-commit rev-parse HEAD) &&
62
+
63
+ run_with_limited_processses env GIT_TRACE="$(pwd)/trace.txt" \
64
+ git -C with-commit-graph fetch origin $anycommit 2>err &&
65
+ ! grep "fatal: promisor-remote: unable to fork off fetch subprocess" err &&
66
+ grep "git fetch origin" trace.txt >actual &&
67
+ test_line_count = 1 actual
68
+'
69
+
70
+test_done