24
test_cmp expect actual
25
'
26
27
+objdir=".git/objects"
28
+
29
test_expect_success 'setup full repo' '
28
- mkdir full &&
29
- cd "$TRASH_DIRECTORY/full" &&
30
- git init &&
31
- git config core.commitGraph true &&
32
- objdir=".git/objects"
30
+ git init full
31
'
32
33
test_expect_success POSIXPERM 'tweak umask for modebit tests' '
35
'
36
37
test_expect_success 'verify graph with no graph file' '
40
- cd "$TRASH_DIRECTORY/full" &&
41
- git commit-graph verify
38
+ git -C full commit-graph verify
39
'
40
41
test_expect_success 'write graph with no packs' '
45
- cd "$TRASH_DIRECTORY/full" &&
46
- git commit-graph write --object-dir $objdir &&
47
- test_path_is_missing $objdir/info/commit-graph
42
+ git -C full commit-graph write --object-dir $objdir &&
43
+ test_path_is_missing full/$objdir/info/commit-graph
44
'
45
46
test_expect_success 'exit with correct error on bad input to --stdin-packs' '
51
- cd "$TRASH_DIRECTORY/full" &&
47
echo doesnotexist >in &&
53
- test_expect_code 1 git commit-graph write --stdin-packs <in 2>stderr &&
48
+ test_expect_code 1 git -C full commit-graph write --stdin-packs \
49
+ <in 2>stderr &&
50
test_i18ngrep "error adding pack" stderr
51
'
52
53
test_expect_success 'create commits and repack' '
58
- cd "$TRASH_DIRECTORY/full" &&
54
for i in $(test_seq 3)
55
do
61
- test_commit $i &&
62
- git branch commits/$i || return 1
56
+ test_commit -C full $i &&
57
+ git -C full branch commits/$i || return 1
58
done &&
64
- git repack
59
+ git -C full repack
60
'
61
62
. "$TEST_DIRECTORY"/lib-commit-graph.sh
64
graph_git_behavior 'no graph' full commits/3 commits/1
65
66
test_expect_success 'exit with correct error on bad input to --stdin-commits' '
72
- cd "$TRASH_DIRECTORY/full" &&
67
# invalid, non-hex OID
74
- echo HEAD >in &&
75
- test_expect_code 1 git commit-graph write --stdin-commits <in 2>stderr &&
68
+ echo HEAD | test_expect_code 1 git -C full commit-graph write \
69
+ --stdin-commits 2>stderr &&
70
test_i18ngrep "unexpected non-hex object ID: HEAD" stderr &&
71
# non-existent OID
78
- echo $ZERO_OID >in &&
79
- test_expect_code 1 git commit-graph write --stdin-commits <in 2>stderr &&
72
+ echo $ZERO_OID | test_expect_code 1 git -C full commit-graph write \
73
+ --stdin-commits 2>stderr &&
74
test_i18ngrep "invalid object" stderr &&
75
# valid commit and tree OID
82
- git rev-parse HEAD HEAD^{tree} >in &&
83
- git commit-graph write --stdin-commits <in &&
84
- graph_read_expect 3 generation_data
76
+ git -C full rev-parse HEAD HEAD^{tree} >in &&
77
+ git -C full commit-graph write --stdin-commits <in &&
78
+ graph_read_expect -C full 3 generation_data
79
'
80
81
test_expect_success 'write graph' '
88
- cd "$TRASH_DIRECTORY/full" &&
89
- git commit-graph write &&
90
- test_path_is_file $objdir/info/commit-graph &&
91
- graph_read_expect "3" generation_data
82
+ git -C full commit-graph write &&
83
+ test_path_is_file full/$objdir/info/commit-graph &&
84
+ graph_read_expect -C full 3 generation_data
85
'
86
87
test_expect_success POSIXPERM 'write graph has correct permissions' '
95
- test_path_is_file $objdir/info/commit-graph &&
88
+ test_path_is_file full/$objdir/info/commit-graph &&
89
echo "-r--r--r--" >expect &&
97
- test_modebits $objdir/info/commit-graph >actual &&
90
+ test_modebits full/$objdir/info/commit-graph >actual &&
91
test_cmp expect actual
92
'
93
94
graph_git_behavior 'graph exists' full commits/3 commits/1
95
96
test_expect_success 'Add more commits' '
104
- cd "$TRASH_DIRECTORY/full" &&
105
- git reset --hard commits/1 &&
97
+ git -C full reset --hard commits/1 &&
98
for i in $(test_seq 4 5)
99
do
108
- test_commit $i &&
109
- git branch commits/$i || return 1
100
+ test_commit -C full $i &&
101
+ git -C full branch commits/$i || return 1
102
done &&
111
- git reset --hard commits/2 &&
103
+ git -C full reset --hard commits/2 &&
104
for i in $(test_seq 6 7)
105
do
114
- test_commit $i &&
115
- git branch commits/$i || return 1
106
+ test_commit -C full $i &&
107
+ git -C full branch commits/$i || return 1
108
done &&
117
- git reset --hard commits/2 &&
118
- git merge commits/4 &&
119
- git branch merge/1 &&
120
- git reset --hard commits/4 &&
121
- git merge commits/6 &&
122
- git branch merge/2 &&
123
- git reset --hard commits/3 &&
124
- git merge commits/5 commits/7 &&
125
- git branch merge/3 &&
126
- git repack
109
+ git -C full reset --hard commits/2 &&
110
+ git -C full merge commits/4 &&
111
+ git -C full branch merge/1 &&
112
+ git -C full reset --hard commits/4 &&
113
+ git -C full merge commits/6 &&
114
+ git -C full branch merge/2 &&
115
+ git -C full reset --hard commits/3 &&
116
+ git -C full merge commits/5 commits/7 &&
117
+ git -C full branch merge/3 &&
118
+ git -C full repack
119
'
120
121
test_expect_success 'commit-graph write progress off for redirected stderr' '
130
- cd "$TRASH_DIRECTORY/full" &&
131
- git commit-graph write 2>err &&
122
+ git -C full commit-graph write 2>err &&
123
test_must_be_empty err
124
'
125
126
test_expect_success 'commit-graph write force progress on for stderr' '
136
- cd "$TRASH_DIRECTORY/full" &&
137
- GIT_PROGRESS_DELAY=0 git commit-graph write --progress 2>err &&
127
+ GIT_PROGRESS_DELAY=0 git -C full commit-graph write --progress 2>err &&
128
test_file_not_empty err
129
'
130
131
test_expect_success 'commit-graph write with the --no-progress option' '
142
- cd "$TRASH_DIRECTORY/full" &&
143
- git commit-graph write --no-progress 2>err &&
132
+ git -C full commit-graph write --no-progress 2>err &&
133
test_must_be_empty err
134
'
135
136
test_expect_success 'commit-graph write --stdin-commits progress off for redirected stderr' '
148
- cd "$TRASH_DIRECTORY/full" &&
149
- git rev-parse commits/5 >in &&
150
- git commit-graph write --stdin-commits <in 2>err &&
137
+ git -C full rev-parse commits/5 >in &&
138
+ git -C full commit-graph write --stdin-commits <in 2>err &&
139
test_must_be_empty err
140
'
141
142
test_expect_success 'commit-graph write --stdin-commits force progress on for stderr' '
155
- cd "$TRASH_DIRECTORY/full" &&
156
- git rev-parse commits/5 >in &&
157
- GIT_PROGRESS_DELAY=0 git commit-graph write --stdin-commits --progress <in 2>err &&
143
+ git -C full rev-parse commits/5 >in &&
144
+ GIT_PROGRESS_DELAY=0 git -C full commit-graph write --stdin-commits \
145
+ --progress <in 2>err &&
146
test_i18ngrep "Collecting commits from input" err
147
'
148
149
test_expect_success 'commit-graph write --stdin-commits with the --no-progress option' '
162
- cd "$TRASH_DIRECTORY/full" &&
163
- git rev-parse commits/5 >in &&
164
- git commit-graph write --stdin-commits --no-progress <in 2>err &&
150
+ git -C full rev-parse commits/5 >in &&
151
+ git -C full commit-graph write --stdin-commits --no-progress <in 2>err &&
152
test_must_be_empty err
153
'
154
155
test_expect_success 'commit-graph verify progress off for redirected stderr' '
169
- cd "$TRASH_DIRECTORY/full" &&
170
- git commit-graph verify 2>err &&
156
+ git -C full commit-graph verify 2>err &&
157
test_must_be_empty err
158
'
159
160
test_expect_success 'commit-graph verify force progress on for stderr' '
175
- cd "$TRASH_DIRECTORY/full" &&
176
- GIT_PROGRESS_DELAY=0 git commit-graph verify --progress 2>err &&
161
+ GIT_PROGRESS_DELAY=0 git -C full commit-graph verify --progress 2>err &&
162
test_file_not_empty err
163
'
164
165
test_expect_success 'commit-graph verify with the --no-progress option' '
181
- cd "$TRASH_DIRECTORY/full" &&
182
- git commit-graph verify --no-progress 2>err &&
166
+ git -C full commit-graph verify --no-progress 2>err &&
167
test_must_be_empty err
168
'
169
178
# 1
179
180
test_expect_success 'write graph with merges' '
197
- cd "$TRASH_DIRECTORY/full" &&
198
- git commit-graph write &&
199
- test_path_is_file $objdir/info/commit-graph &&
200
- graph_read_expect "10" "generation_data extra_edges"
181
+ git -C full commit-graph write &&
182
+ test_path_is_file full/$objdir/info/commit-graph &&
183
+ graph_read_expect -C full 10 "generation_data extra_edges"
184
'
185
186
graph_git_behavior 'merge 1 vs 2' full merge/1 merge/2
188
graph_git_behavior 'merge 2 vs 3' full merge/2 merge/3
189
190
test_expect_success 'Add one more commit' '
208
- cd "$TRASH_DIRECTORY/full" &&
209
- test_commit 8 &&
210
- git branch commits/8 &&
211
- ls $objdir/pack | grep idx >existing-idx &&
212
- git repack &&
213
- ls $objdir/pack| grep idx | grep -v -f existing-idx >new-idx
191
+ test_commit -C full 8 &&
192
+ git -C full branch commits/8 &&
193
+ ls full/$objdir/pack | grep idx >existing-idx &&
194
+ git -C full repack &&
195
+ ls full/$objdir/pack| grep idx | grep -v -f existing-idx >new-idx
196
'
197
198
# Current graph structure:
211
graph_git_behavior 'mixed mode, commit 8 vs merge 2' full commits/8 merge/2
212
213
test_expect_success 'write graph with new commit' '
232
- cd "$TRASH_DIRECTORY/full" &&
233
- git commit-graph write &&
234
- test_path_is_file $objdir/info/commit-graph &&
235
- graph_read_expect "11" "generation_data extra_edges"
214
+ git -C full commit-graph write &&
215
+ test_path_is_file full/$objdir/info/commit-graph &&
216
+ graph_read_expect -C full 11 "generation_data extra_edges"
217
'
218
219
graph_git_behavior 'full graph, commit 8 vs merge 1' full commits/8 merge/1
220
graph_git_behavior 'full graph, commit 8 vs merge 2' full commits/8 merge/2
221
222
test_expect_success 'write graph with nothing new' '
242
- cd "$TRASH_DIRECTORY/full" &&
243
- git commit-graph write &&
244
- test_path_is_file $objdir/info/commit-graph &&
245
- graph_read_expect "11" "generation_data extra_edges"
223
+ git -C full commit-graph write &&
224
+ test_path_is_file full/$objdir/info/commit-graph &&
225
+ graph_read_expect -C full 11 "generation_data extra_edges"
226
'
227
228
graph_git_behavior 'cleared graph, commit 8 vs merge 1' full commits/8 merge/1
229
graph_git_behavior 'cleared graph, commit 8 vs merge 2' full commits/8 merge/2
230
231
test_expect_success 'build graph from latest pack with closure' '
252
- cd "$TRASH_DIRECTORY/full" &&
253
- cat new-idx | git commit-graph write --stdin-packs &&
254
- test_path_is_file $objdir/info/commit-graph &&
255
- graph_read_expect "9" "generation_data extra_edges"
232
+ git -C full commit-graph write --stdin-packs <new-idx &&
233
+ test_path_is_file full/$objdir/info/commit-graph &&
234
+ graph_read_expect -C full 9 "generation_data extra_edges"
235
'
236
237
graph_git_behavior 'graph from pack, commit 8 vs merge 1' full commits/8 merge/1
238
graph_git_behavior 'graph from pack, commit 8 vs merge 2' full commits/8 merge/2
239
240
test_expect_success 'build graph from commits with closure' '
262
- cd "$TRASH_DIRECTORY/full" &&
263
- git tag -a -m "merge" tag/merge merge/2 &&
264
- git rev-parse tag/merge >commits-in &&
265
- git rev-parse merge/1 >>commits-in &&
266
- cat commits-in | git commit-graph write --stdin-commits &&
267
- test_path_is_file $objdir/info/commit-graph &&
268
- graph_read_expect "6" "generation_data"
241
+ git -C full tag -a -m "merge" tag/merge merge/2 &&
242
+ git -C full rev-parse tag/merge >commits-in &&
243
+ git -C full rev-parse merge/1 >>commits-in &&
244
+ git -C full commit-graph write --stdin-commits <commits-in &&
245
+ test_path_is_file full/$objdir/info/commit-graph &&
246
+ graph_read_expect -C full 6 "generation_data"
247
'
248
249
graph_git_behavior 'graph from commits, commit 8 vs merge 1' full commits/8 merge/1
250
graph_git_behavior 'graph from commits, commit 8 vs merge 2' full commits/8 merge/2
251
252
test_expect_success 'build graph from commits with append' '
275
- cd "$TRASH_DIRECTORY/full" &&
276
- git rev-parse merge/3 | git commit-graph write --stdin-commits --append &&
277
- test_path_is_file $objdir/info/commit-graph &&
278
- graph_read_expect "10" "generation_data extra_edges"
253
+ git -C full rev-parse merge/3 >in &&
254
+ git -C full commit-graph write --stdin-commits --append <in &&
255
+ test_path_is_file full/$objdir/info/commit-graph &&
256
+ graph_read_expect -C full 10 "generation_data extra_edges"
257
'
258
259
graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
260
graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
261
262
test_expect_success 'build graph using --reachable' '
285
- cd "$TRASH_DIRECTORY/full" &&
286
- git commit-graph write --reachable &&
287
- test_path_is_file $objdir/info/commit-graph &&
288
- graph_read_expect "11" "generation_data extra_edges"
263
+ git -C full commit-graph write --reachable &&
264
+ test_path_is_file full/$objdir/info/commit-graph &&
265
+ graph_read_expect -C full 11 "generation_data extra_edges"
266
'
267
268
graph_git_behavior 'append graph, commit 8 vs merge 1' full commits/8 merge/1
269
graph_git_behavior 'append graph, commit 8 vs merge 2' full commits/8 merge/2
270
271
test_expect_success 'setup bare repo' '
295
- cd "$TRASH_DIRECTORY" &&
296
- git clone --bare --no-local full bare &&
297
- cd bare &&
298
- git config core.commitGraph true &&
299
- baredir="./objects"
272
+ git clone --bare --no-local full bare
273
'
274
275
graph_git_behavior 'bare repo, commit 8 vs merge 1' bare commits/8 merge/1
276
graph_git_behavior 'bare repo, commit 8 vs merge 2' bare commits/8 merge/2
277
278
test_expect_success 'write graph in bare repo' '
306
- cd "$TRASH_DIRECTORY/bare" &&
307
- git commit-graph write &&
308
- test_path_is_file $baredir/info/commit-graph &&
309
- graph_read_expect "11" "generation_data extra_edges"
279
+ git -C bare commit-graph write &&
280
+ test_path_is_file bare/objects/info/commit-graph &&
281
+ graph_read_expect -C bare 11 "generation_data extra_edges"
282
'
283
284
graph_git_behavior 'bare repo with graph, commit 8 vs merge 1' bare commits/8 merge/1
285
graph_git_behavior 'bare repo with graph, commit 8 vs merge 2' bare commits/8 merge/2
286
287
test_expect_success 'perform fast-forward merge in full repo' '
316
- cd "$TRASH_DIRECTORY/full" &&
317
- git checkout -b merge-5-to-8 commits/5 &&
318
- git merge commits/8 &&
319
- git show-ref -s merge-5-to-8 >output &&
320
- git show-ref -s commits/8 >expect &&
288
+ git -C full checkout -b merge-5-to-8 commits/5 &&
289
+ git -C full merge commits/8 &&
290
+ git -C full show-ref -s merge-5-to-8 >output &&
291
+ git -C full show-ref -s commits/8 >expect &&
292
test_cmp expect output
293
'
294
295
test_expect_success 'check that gc computes commit-graph' '
325
- cd "$TRASH_DIRECTORY/full" &&
326
- git commit --allow-empty -m "blank" &&
327
- git commit-graph write --reachable &&
328
- cp $objdir/info/commit-graph commit-graph-before-gc &&
329
- git reset --hard HEAD~1 &&
330
- git config gc.writeCommitGraph true &&
331
- git gc &&
332
- cp $objdir/info/commit-graph commit-graph-after-gc &&
296
+ test_commit -C full --no-tag blank &&
297
+ git -C full commit-graph write --reachable &&
298
+ cp full/$objdir/info/commit-graph commit-graph-before-gc &&
299
+ git -C full reset --hard HEAD~1 &&
300
+ test_config -C full gc.writeCommitGraph true &&
301
+ git -C full gc &&
302
+ cp full/$objdir/info/commit-graph commit-graph-after-gc &&
303
! test_cmp_bin commit-graph-before-gc commit-graph-after-gc &&
334
- git commit-graph write --reachable &&
335
- test_cmp_bin commit-graph-after-gc $objdir/info/commit-graph
304
+ git -C full commit-graph write --reachable &&
305
+ test_cmp_bin commit-graph-after-gc full/$objdir/info/commit-graph
306
'
307
308
test_expect_success 'replace-objects invalidates commit-graph' '
339
- cd "$TRASH_DIRECTORY" &&
309
test_when_finished rm -rf replace &&
310
git clone full replace &&
311
(
328
'
329
330
test_expect_success 'commit grafts invalidate commit-graph' '
362
- cd "$TRASH_DIRECTORY" &&
331
test_when_finished rm -rf graft &&
332
git clone --template= full graft &&
333
(
352
'
353
354
test_expect_success 'replace-objects invalidates commit-graph' '
387
- cd "$TRASH_DIRECTORY" &&
355
test_when_finished rm -rf shallow &&
356
git clone --depth 2 "file://$TRASH_DIRECTORY/full" shallow &&
357
(
394
'
395
396
test_expect_success TIME_IS_64BIT,TIME_T_IS_64BIT 'lower layers have overflow chunk' '
430
- cd "$TRASH_DIRECTORY/full" &&
397
UNIX_EPOCH_ZERO="@0 +0000" &&
398
FUTURE_DATE="@4147483646 +0000" &&
433
- rm -f .git/objects/info/commit-graph &&
434
- test_commit --date "$FUTURE_DATE" future-1 &&
435
- test_commit --date "$UNIX_EPOCH_ZERO" old-1 &&
436
- git commit-graph write --reachable &&
437
- test_commit --date "$FUTURE_DATE" future-2 &&
438
- test_commit --date "$UNIX_EPOCH_ZERO" old-2 &&
439
- git commit-graph write --reachable --split=no-merge &&
440
- test_commit extra &&
441
- git commit-graph write --reachable --split=no-merge &&
442
- git commit-graph write --reachable &&
443
- graph_read_expect 16 "generation_data generation_data_overflow extra_edges" &&
444
- mv .git/objects/info/commit-graph commit-graph-upgraded &&
445
- git commit-graph write --reachable &&
446
- graph_read_expect 16 "generation_data generation_data_overflow extra_edges" &&
447
- test_cmp .git/objects/info/commit-graph commit-graph-upgraded
399
+ rm -f full/.git/objects/info/commit-graph &&
400
+ test_commit -C full --date "$FUTURE_DATE" future-1 &&
401
+ test_commit -C full --date "$UNIX_EPOCH_ZERO" old-1 &&
402
+ git -C full commit-graph write --reachable &&
403
+ test_commit -C full --date "$FUTURE_DATE" future-2 &&
404
+ test_commit -C full --date "$UNIX_EPOCH_ZERO" old-2 &&
405
+ git -C full commit-graph write --reachable --split=no-merge &&
406
+ test_commit -C full extra &&
407
+ git -C full commit-graph write --reachable --split=no-merge &&
408
+ git -C full commit-graph write --reachable &&
409
+ graph_read_expect -C full 16 \
410
+ "generation_data generation_data_overflow extra_edges" &&
411
+ mv full/.git/objects/info/commit-graph commit-graph-upgraded &&
412
+ git -C full commit-graph write --reachable &&
413
+ graph_read_expect -C full 16 \
414
+ "generation_data generation_data_overflow extra_edges" &&
415
+ test_cmp full/.git/objects/info/commit-graph commit-graph-upgraded
416
'
417
418
# the verify tests below expect the commit-graph to contain
422
# and the tests will likely break.
423
424
test_expect_success 'git commit-graph verify' '
457
- cd "$TRASH_DIRECTORY/full" &&
458
- git rev-parse commits/8 | git -c commitGraph.generationVersion=1 commit-graph write --stdin-commits &&
459
- git commit-graph verify >output &&
460
- graph_read_expect 9 extra_edges 1
425
+ git -C full rev-parse commits/8 >in &&
426
+ git -C full -c commitGraph.generationVersion=1 commit-graph write \
427
+ --stdin-commits <in &&
428
+ git -C full commit-graph verify >output &&
429
+ graph_read_expect -C full 9 extra_edges 1
430
'
431
432
NUM_COMMITS=9
464
GRAPH_BYTE_FOOTER=$(($GRAPH_OCTOPUS_DATA_OFFSET + 4 * $NUM_OCTOPUS_EDGES))
465
466
corrupt_graph_setup() {
498
- cd "$TRASH_DIRECTORY/full" &&
499
- test_when_finished mv commit-graph-backup $objdir/info/commit-graph &&
500
- cp $objdir/info/commit-graph commit-graph-backup &&
501
- chmod u+w $objdir/info/commit-graph
467
+ test_when_finished mv commit-graph-backup full/$objdir/info/commit-graph &&
468
+ cp full/$objdir/info/commit-graph commit-graph-backup &&
469
+ chmod u+w full/$objdir/info/commit-graph
470
}
471
472
corrupt_graph_verify() {
473
grepstr=$1
506
- test_must_fail git commit-graph verify 2>test_err &&
474
+ test_must_fail git -C full commit-graph verify 2>test_err &&
475
grep -v "^+" test_err >err &&
476
test_i18ngrep "$grepstr" err &&
477
if test "$2" != "no-copy"
478
then
511
- cp $objdir/info/commit-graph commit-graph-pre-write-test
479
+ cp full/$objdir/info/commit-graph commit-graph-pre-write-test
480
fi &&
513
- git status --short &&
514
- GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE=true git commit-graph write &&
515
- chmod u+w $objdir/info/commit-graph &&
516
- git commit-graph verify
481
+ git -C full status --short &&
482
+ GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE=true git -C full commit-graph write &&
483
+ chmod u+w full/$objdir/info/commit-graph &&
484
+ git -C full commit-graph verify
485
}
486
487
# usage: corrupt_graph_and_verify <position> <data> <string> [<zero_pos>]
495
data="${2:-\0}"
496
grepstr=$3
497
corrupt_graph_setup &&
530
- orig_size=$(wc -c < $objdir/info/commit-graph) &&
498
+ orig_size=$(wc -c <full/$objdir/info/commit-graph) &&
499
zero_pos=${4:-${orig_size}} &&
532
- printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
533
- dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
534
- test-tool genzeros $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
500
+ printf "$data" | dd of="full/$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
501
+ dd of="full/$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
502
+ test-tool genzeros $(($orig_size - $zero_pos)) >>"full/$objdir/info/commit-graph" &&
503
corrupt_graph_verify "$grepstr"
504
505
}
506
507
test_expect_success POSIXPERM,SANITY 'detect permission problem' '
508
corrupt_graph_setup &&
541
- chmod 000 $objdir/info/commit-graph &&
509
+ chmod 000 full/$objdir/info/commit-graph &&
510
corrupt_graph_verify "Could not open" "no-copy"
511
'
512
513
test_expect_success 'detect too small' '
514
corrupt_graph_setup &&
547
- echo "a small graph" >$objdir/info/commit-graph &&
515
+ echo "a small graph" >full/$objdir/info/commit-graph &&
516
corrupt_graph_verify "too small"
517
'
518
623
'
624
625
test_expect_success 'git fsck (checks commit-graph when config set to true)' '
658
- cd "$TRASH_DIRECTORY/full" &&
659
- git fsck &&
626
+ git -C full fsck &&
627
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
628
"incorrect checksum" &&
662
- cp commit-graph-pre-write-test $objdir/info/commit-graph &&
663
- test_must_fail git -c core.commitGraph=true fsck
629
+ cp commit-graph-pre-write-test full/$objdir/info/commit-graph &&
630
+ test_must_fail git -C full -c core.commitGraph=true fsck
631
'
632
633
test_expect_success 'git fsck (ignores commit-graph when config set to false)' '
667
- cd "$TRASH_DIRECTORY/full" &&
668
- git fsck &&
634
+ git -C full fsck &&
635
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
636
"incorrect checksum" &&
671
- cp commit-graph-pre-write-test $objdir/info/commit-graph &&
672
- git -c core.commitGraph=false fsck
637
+ cp commit-graph-pre-write-test full/$objdir/info/commit-graph &&
638
+ git -C full -c core.commitGraph=false fsck
639
'
640
641
test_expect_success 'git fsck (checks commit-graph when config unset)' '
676
- cd "$TRASH_DIRECTORY/full" &&
677
- test_when_finished "git config core.commitGraph true" &&
642
+ test_when_finished "git -C full config core.commitGraph true" &&
643
679
- git fsck &&
644
+ git -C full fsck &&
645
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
646
"incorrect checksum" &&
682
- test_unconfig core.commitGraph &&
683
- cp commit-graph-pre-write-test $objdir/info/commit-graph &&
684
- test_must_fail git fsck
647
+ test_unconfig -C full core.commitGraph &&
648
+ cp commit-graph-pre-write-test full/$objdir/info/commit-graph &&
649
+ test_must_fail git -C full fsck
650
'
651
652
test_expect_success 'git fsck shows commit-graph output with --progress' '
757
#
758
759
test_expect_success 'set up and verify repo with generation data overflow chunk' '
795
- objdir=".git/objects" &&
760
UNIX_EPOCH_ZERO="@0 +0000" &&
761
FUTURE_DATE="@2147483646 +0000" &&
798
- cd "$TRASH_DIRECTORY" &&
799
- mkdir repo &&
800
- cd repo &&
801
- git init &&
802
- test_commit --date "$UNIX_EPOCH_ZERO" 1 &&
803
- test_commit 2 &&
804
- test_commit --date "$UNIX_EPOCH_ZERO" 3 &&
805
- git commit-graph write --reachable &&
806
- graph_read_expect 3 generation_data &&
807
- test_commit --date "$FUTURE_DATE" 4 &&
808
- test_commit 5 &&
809
- test_commit --date "$UNIX_EPOCH_ZERO" 6 &&
810
- git branch left &&
811
- git reset --hard 3 &&
812
- test_commit 7 &&
813
- test_commit --date "$FUTURE_DATE" 8 &&
814
- test_commit 9 &&
815
- git branch right &&
816
- git reset --hard 3 &&
817
- test_merge M left right &&
818
- git commit-graph write --reachable &&
819
- graph_read_expect 10 "generation_data generation_data_overflow" &&
820
- git commit-graph verify
762
+
763
+ git init repo &&
764
+ (
765
+ cd repo &&
766
+
767
+ test_commit --date "$UNIX_EPOCH_ZERO" 1 &&
768
+ test_commit 2 &&
769
+ test_commit --date "$UNIX_EPOCH_ZERO" 3 &&
770
+ git commit-graph write --reachable &&
771
+ graph_read_expect 3 generation_data &&
772
+ test_commit --date "$FUTURE_DATE" 4 &&
773
+ test_commit 5 &&
774
+ test_commit --date "$UNIX_EPOCH_ZERO" 6 &&
775
+ git branch left &&
776
+ git reset --hard 3 &&
777
+ test_commit 7 &&
778
+ test_commit --date "$FUTURE_DATE" 8 &&
779
+ test_commit 9 &&
780
+ git branch right &&
781
+ git reset --hard 3 &&
782
+ test_merge M left right &&
783
+ git commit-graph write --reachable &&
784
+ graph_read_expect 10 "generation_data generation_data_overflow" &&
785
+ git commit-graph verify
786
+ )
787
'
788
789
graph_git_behavior 'generation data overflow chunk repo' repo left right