]>
Commit | Line | Data |
---|---|---|
f237c8b6 DS |
1 | #!/bin/sh |
2 | ||
3 | test_description='commit graph' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup full repo' ' | |
7 | mkdir full && | |
8 | cd "$TRASH_DIRECTORY/full" && | |
9 | git init && | |
10 | objdir=".git/objects" | |
11 | ' | |
12 | ||
13 | test_expect_success 'write graph with no packs' ' | |
14 | cd "$TRASH_DIRECTORY/full" && | |
15 | git commit-graph write --object-dir . && | |
16 | test_path_is_file info/commit-graph | |
17 | ' | |
18 | ||
19 | test_expect_success 'create commits and repack' ' | |
20 | cd "$TRASH_DIRECTORY/full" && | |
21 | for i in $(test_seq 3) | |
22 | do | |
23 | test_commit $i && | |
24 | git branch commits/$i | |
25 | done && | |
26 | git repack | |
27 | ' | |
28 | ||
2a2e32bd DS |
29 | graph_read_expect() { |
30 | OPTIONAL="" | |
31 | NUM_CHUNKS=3 | |
32 | if test ! -z $2 | |
33 | then | |
34 | OPTIONAL=" $2" | |
35 | NUM_CHUNKS=$((3 + $(echo "$2" | wc -w))) | |
36 | fi | |
37 | cat >expect <<- EOF | |
38 | header: 43475048 1 1 $NUM_CHUNKS 0 | |
39 | num_commits: $1 | |
40 | chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL | |
41 | EOF | |
42 | git commit-graph read >output && | |
43 | test_cmp expect output | |
44 | } | |
45 | ||
f237c8b6 DS |
46 | test_expect_success 'write graph' ' |
47 | cd "$TRASH_DIRECTORY/full" && | |
48 | graph1=$(git commit-graph write) && | |
2a2e32bd DS |
49 | test_path_is_file $objdir/info/commit-graph && |
50 | graph_read_expect "3" | |
f237c8b6 DS |
51 | ' |
52 | ||
53 | test_expect_success 'Add more commits' ' | |
54 | cd "$TRASH_DIRECTORY/full" && | |
55 | git reset --hard commits/1 && | |
56 | for i in $(test_seq 4 5) | |
57 | do | |
58 | test_commit $i && | |
59 | git branch commits/$i | |
60 | done && | |
61 | git reset --hard commits/2 && | |
62 | for i in $(test_seq 6 7) | |
63 | do | |
64 | test_commit $i && | |
65 | git branch commits/$i | |
66 | done && | |
67 | git reset --hard commits/2 && | |
68 | git merge commits/4 && | |
69 | git branch merge/1 && | |
70 | git reset --hard commits/4 && | |
71 | git merge commits/6 && | |
72 | git branch merge/2 && | |
73 | git reset --hard commits/3 && | |
74 | git merge commits/5 commits/7 && | |
75 | git branch merge/3 && | |
76 | git repack | |
77 | ' | |
78 | ||
79 | # Current graph structure: | |
80 | # | |
81 | # __M3___ | |
82 | # / | \ | |
83 | # 3 M1 5 M2 7 | |
84 | # |/ \|/ \| | |
85 | # 2 4 6 | |
86 | # |___/____/ | |
87 | # 1 | |
88 | ||
89 | ||
90 | test_expect_success 'write graph with merges' ' | |
91 | cd "$TRASH_DIRECTORY/full" && | |
92 | git commit-graph write && | |
2a2e32bd DS |
93 | test_path_is_file $objdir/info/commit-graph && |
94 | graph_read_expect "10" "large_edges" | |
f237c8b6 DS |
95 | ' |
96 | ||
97 | test_expect_success 'Add one more commit' ' | |
98 | cd "$TRASH_DIRECTORY/full" && | |
99 | test_commit 8 && | |
100 | git branch commits/8 && | |
101 | ls $objdir/pack | grep idx >existing-idx && | |
102 | git repack && | |
103 | ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx | |
104 | ' | |
105 | ||
106 | # Current graph structure: | |
107 | # | |
108 | # 8 | |
109 | # | | |
110 | # __M3___ | |
111 | # / | \ | |
112 | # 3 M1 5 M2 7 | |
113 | # |/ \|/ \| | |
114 | # 2 4 6 | |
115 | # |___/____/ | |
116 | # 1 | |
117 | ||
118 | test_expect_success 'write graph with new commit' ' | |
119 | cd "$TRASH_DIRECTORY/full" && | |
120 | git commit-graph write && | |
2a2e32bd DS |
121 | test_path_is_file $objdir/info/commit-graph && |
122 | graph_read_expect "11" "large_edges" | |
f237c8b6 DS |
123 | ' |
124 | ||
125 | test_expect_success 'write graph with nothing new' ' | |
126 | cd "$TRASH_DIRECTORY/full" && | |
127 | git commit-graph write && | |
2a2e32bd DS |
128 | test_path_is_file $objdir/info/commit-graph && |
129 | graph_read_expect "11" "large_edges" | |
f237c8b6 DS |
130 | ' |
131 | ||
132 | test_expect_success 'setup bare repo' ' | |
133 | cd "$TRASH_DIRECTORY" && | |
134 | git clone --bare --no-local full bare && | |
135 | cd bare && | |
136 | baredir="./objects" | |
137 | ' | |
138 | ||
139 | test_expect_success 'write graph in bare repo' ' | |
140 | cd "$TRASH_DIRECTORY/bare" && | |
141 | git commit-graph write && | |
2a2e32bd DS |
142 | test_path_is_file $baredir/info/commit-graph && |
143 | graph_read_expect "11" "large_edges" | |
f237c8b6 DS |
144 | ' |
145 | ||
146 | test_done |