pack-objects: split out `--stdin-packs` tests into separate file
The test suite for git-pack-objects(1) is quite huge, and we're about to add more tests that relate to the `--stdin-packs` option. Split out all tests related to this option into a standalone file so that it becomes easier to test the feature in isolation. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Apr 14, 2023 at 08:01 UTC
b7b8f048f567f1dde24874e82227fbf2c64a1aed
2 files changed
+145
-135
t/t5300-pack-object.sh
-135
@@ -589,141 +589,6 @@ test_expect_success 'prefetch objects' '
589
test_line_count = 1 donelines
590
'
591
592
-test_expect_success 'setup for --stdin-packs tests' '
593
- git init stdin-packs &&
594
- (
595
- cd stdin-packs &&
596
-
597
- test_commit A &&
598
- test_commit B &&
599
- test_commit C &&
600
-
601
- for id in A B C
602
- do
603
- git pack-objects .git/objects/pack/pack-$id \
604
- --incremental --revs <<-EOF || exit 1
605
- refs/tags/$id
606
- EOF
607
- done &&
608
-
609
- ls -la .git/objects/pack
610
- )
611
-'
612
-
613
-test_expect_success '--stdin-packs with excluded packs' '
614
- (
615
- cd stdin-packs &&
616
-
617
- PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
618
- PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
619
- PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
620
-
621
- git pack-objects test --stdin-packs <<-EOF &&
622
- $PACK_A
623
- ^$PACK_B
624
- $PACK_C
625
- EOF
626
-
627
- (
628
- git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
629
- git show-index <$(ls .git/objects/pack/pack-C-*.idx)
630
- ) >expect.raw &&
631
- git show-index <$(ls test-*.idx) >actual.raw &&
632
-
633
- cut -d" " -f2 <expect.raw | sort >expect &&
634
- cut -d" " -f2 <actual.raw | sort >actual &&
635
- test_cmp expect actual
636
- )
637
-'
638
-
639
-test_expect_success '--stdin-packs is incompatible with --filter' '
640
- (
641
- cd stdin-packs &&
642
- test_must_fail git pack-objects --stdin-packs --stdout \
643
- --filter=blob:none </dev/null 2>err &&
644
- test_i18ngrep "cannot use --filter with --stdin-packs" err
645
- )
646
-'
647
-
648
-test_expect_success '--stdin-packs is incompatible with --revs' '
649
- (
650
- cd stdin-packs &&
651
- test_must_fail git pack-objects --stdin-packs --revs out \
652
- </dev/null 2>err &&
653
- test_i18ngrep "cannot use internal rev list with --stdin-packs" err
654
- )
655
-'
656
-
657
-test_expect_success '--stdin-packs with loose objects' '
658
- (
659
- cd stdin-packs &&
660
-
661
- PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
662
- PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
663
- PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
664
-
665
- test_commit D && # loose
666
-
667
- git pack-objects test2 --stdin-packs --unpacked <<-EOF &&
668
- $PACK_A
669
- ^$PACK_B
670
- $PACK_C
671
- EOF
672
-
673
- (
674
- git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
675
- git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
676
- git rev-list --objects --no-object-names \
677
- refs/tags/C..refs/tags/D
678
-
679
- ) >expect.raw &&
680
- ls -la . &&
681
- git show-index <$(ls test2-*.idx) >actual.raw &&
682
-
683
- cut -d" " -f2 <expect.raw | sort >expect &&
684
- cut -d" " -f2 <actual.raw | sort >actual &&
685
- test_cmp expect actual
686
- )
687
-'
688
-
689
-test_expect_success '--stdin-packs with broken links' '
690
- (
691
- cd stdin-packs &&
692
-
693
- # make an unreachable object with a bogus parent
694
- git cat-file -p HEAD >commit &&
695
- sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit |
696
- git hash-object -w -t commit --stdin >in &&
697
-
698
- git pack-objects .git/objects/pack/pack-D <in &&
699
-
700
- PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
701
- PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
702
- PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
703
- PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" &&
704
-
705
- git pack-objects test3 --stdin-packs --unpacked <<-EOF &&
706
- $PACK_A
707
- ^$PACK_B
708
- $PACK_C
709
- $PACK_D
710
- EOF
711
-
712
- (
713
- git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
714
- git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
715
- git show-index <$(ls .git/objects/pack/pack-D-*.idx) &&
716
- git rev-list --objects --no-object-names \
717
- refs/tags/C..refs/tags/D
718
- ) >expect.raw &&
719
- git show-index <$(ls test3-*.idx) >actual.raw &&
720
-
721
- cut -d" " -f2 <expect.raw | sort >expect &&
722
- cut -d" " -f2 <actual.raw | sort >actual &&
723
- test_cmp expect actual
724
- )
725
-'
726
-
592
test_expect_success 'negative window clamps to 0' '
593
git pack-objects --progress --window=-1 neg-window <obj-list 2>stderr &&
594
check_deltas stderr = 0
t/t5331-pack-objects-stdin.sh
new
+145
@@ -0,0 +1,145 @@
1
+#!/bin/sh
2
+
3
+test_description='pack-objects --stdin'
4
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
+
7
+TEST_PASSES_SANITIZE_LEAK=true
8
+. ./test-lib.sh
9
+
10
+test_expect_success 'setup for --stdin-packs tests' '
11
+ git init stdin-packs &&
12
+ (
13
+ cd stdin-packs &&
14
+
15
+ test_commit A &&
16
+ test_commit B &&
17
+ test_commit C &&
18
+
19
+ for id in A B C
20
+ do
21
+ git pack-objects .git/objects/pack/pack-$id \
22
+ --incremental --revs <<-EOF || exit 1
23
+ refs/tags/$id
24
+ EOF
25
+ done &&
26
+
27
+ ls -la .git/objects/pack
28
+ )
29
+'
30
+
31
+test_expect_success '--stdin-packs with excluded packs' '
32
+ (
33
+ cd stdin-packs &&
34
+
35
+ PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
36
+ PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
37
+ PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
38
+
39
+ git pack-objects test --stdin-packs <<-EOF &&
40
+ $PACK_A
41
+ ^$PACK_B
42
+ $PACK_C
43
+ EOF
44
+
45
+ (
46
+ git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
47
+ git show-index <$(ls .git/objects/pack/pack-C-*.idx)
48
+ ) >expect.raw &&
49
+ git show-index <$(ls test-*.idx) >actual.raw &&
50
+
51
+ cut -d" " -f2 <expect.raw | sort >expect &&
52
+ cut -d" " -f2 <actual.raw | sort >actual &&
53
+ test_cmp expect actual
54
+ )
55
+'
56
+
57
+test_expect_success '--stdin-packs is incompatible with --filter' '
58
+ (
59
+ cd stdin-packs &&
60
+ test_must_fail git pack-objects --stdin-packs --stdout \
61
+ --filter=blob:none </dev/null 2>err &&
62
+ test_i18ngrep "cannot use --filter with --stdin-packs" err
63
+ )
64
+'
65
+
66
+test_expect_success '--stdin-packs is incompatible with --revs' '
67
+ (
68
+ cd stdin-packs &&
69
+ test_must_fail git pack-objects --stdin-packs --revs out \
70
+ </dev/null 2>err &&
71
+ test_i18ngrep "cannot use internal rev list with --stdin-packs" err
72
+ )
73
+'
74
+
75
+test_expect_success '--stdin-packs with loose objects' '
76
+ (
77
+ cd stdin-packs &&
78
+
79
+ PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
80
+ PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
81
+ PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
82
+
83
+ test_commit D && # loose
84
+
85
+ git pack-objects test2 --stdin-packs --unpacked <<-EOF &&
86
+ $PACK_A
87
+ ^$PACK_B
88
+ $PACK_C
89
+ EOF
90
+
91
+ (
92
+ git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
93
+ git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
94
+ git rev-list --objects --no-object-names \
95
+ refs/tags/C..refs/tags/D
96
+
97
+ ) >expect.raw &&
98
+ ls -la . &&
99
+ git show-index <$(ls test2-*.idx) >actual.raw &&
100
+
101
+ cut -d" " -f2 <expect.raw | sort >expect &&
102
+ cut -d" " -f2 <actual.raw | sort >actual &&
103
+ test_cmp expect actual
104
+ )
105
+'
106
+
107
+test_expect_success '--stdin-packs with broken links' '
108
+ (
109
+ cd stdin-packs &&
110
+
111
+ # make an unreachable object with a bogus parent
112
+ git cat-file -p HEAD >commit &&
113
+ sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit |
114
+ git hash-object -w -t commit --stdin >in &&
115
+
116
+ git pack-objects .git/objects/pack/pack-D <in &&
117
+
118
+ PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
119
+ PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
120
+ PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
121
+ PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" &&
122
+
123
+ git pack-objects test3 --stdin-packs --unpacked <<-EOF &&
124
+ $PACK_A
125
+ ^$PACK_B
126
+ $PACK_C
127
+ $PACK_D
128
+ EOF
129
+
130
+ (
131
+ git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
132
+ git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
133
+ git show-index <$(ls .git/objects/pack/pack-D-*.idx) &&
134
+ git rev-list --objects --no-object-names \
135
+ refs/tags/C..refs/tags/D
136
+ ) >expect.raw &&
137
+ git show-index <$(ls test3-*.idx) >actual.raw &&
138
+
139
+ cut -d" " -f2 <expect.raw | sort >expect &&
140
+ cut -d" " -f2 <actual.raw | sort >actual &&
141
+ test_cmp expect actual
142
+ )
143
+'
144
+
145
+test_done