@@ -21,6 +21,25 @@ test_no_missing_in_packs () {
21
21
test_must_be_empty missing
22
22
}
23
23
24
+ # we expect $packsha1 and $objsha1 to be defined
25
+ test_has_duplicate_object () {
26
+ want_duplicate_object=" $1 "
27
+ found_duplicate_object=false
28
+ for p in .git/objects/pack/* .idx
29
+ do
30
+ idx=$( basename $p )
31
+ test " pack-$packsha1 .idx" = " $idx " && continue
32
+ git verify-pack -v $p > packlist || return $?
33
+ if egrep " ^$objsha1 " packlist
34
+ then
35
+ found_duplicate_object=true
36
+ echo " DUPLICATE OBJECT FOUND"
37
+ break
38
+ fi
39
+ done &&
40
+ test " $want_duplicate_object " = " $found_duplicate_object "
41
+ }
42
+
24
43
test_expect_success ' objects in packs marked .keep are not repacked' '
25
44
echo content1 >file1 &&
26
45
echo content2 >file2 &&
@@ -40,54 +59,19 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
40
59
mv pack-* .git/objects/pack/ &&
41
60
git repack -A -d -l &&
42
61
git prune-packed &&
43
- for p in .git/objects/pack/*.idx
44
- do
45
- idx=$(basename $p)
46
- test "pack-$packsha1.idx" = "$idx" && continue
47
- if git verify-pack -v $p | egrep "^$objsha1"
48
- then
49
- found_duplicate_object=1
50
- echo "DUPLICATE OBJECT FOUND"
51
- break
52
- fi
53
- done &&
54
- test -z "$found_duplicate_object"
62
+ test_has_duplicate_object false
55
63
'
56
64
57
65
test_expect_success ' writing bitmaps via command-line can duplicate .keep objects' '
58
66
# build on $objsha1, $packsha1, and .keep state from previous
59
67
git repack -Adbl &&
60
- test_when_finished "found_duplicate_object=" &&
61
- for p in .git/objects/pack/*.idx
62
- do
63
- idx=$(basename $p)
64
- test "pack-$packsha1.idx" = "$idx" && continue
65
- if git verify-pack -v $p | egrep "^$objsha1"
66
- then
67
- found_duplicate_object=1
68
- echo "DUPLICATE OBJECT FOUND"
69
- break
70
- fi
71
- done &&
72
- test "$found_duplicate_object" = 1
68
+ test_has_duplicate_object true
73
69
'
74
70
75
71
test_expect_success ' writing bitmaps via config can duplicate .keep objects' '
76
72
# build on $objsha1, $packsha1, and .keep state from previous
77
73
git -c repack.writebitmaps=true repack -Adl &&
78
- test_when_finished "found_duplicate_object=" &&
79
- for p in .git/objects/pack/*.idx
80
- do
81
- idx=$(basename $p)
82
- test "pack-$packsha1.idx" = "$idx" && continue
83
- if git verify-pack -v $p | egrep "^$objsha1"
84
- then
85
- found_duplicate_object=1
86
- echo "DUPLICATE OBJECT FOUND"
87
- break
88
- fi
89
- done &&
90
- test "$found_duplicate_object" = 1
74
+ test_has_duplicate_object true
91
75
'
92
76
93
77
test_expect_success ' loose objects in alternate ODB are not repacked' '
@@ -100,16 +84,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' '
100
84
git commit -m commit_file3 &&
101
85
git repack -a -d -l &&
102
86
git prune-packed &&
103
- for p in .git/objects/pack/*.idx
104
- do
105
- if git verify-pack -v $p | egrep "^$objsha1"
106
- then
107
- found_duplicate_object=1
108
- echo "DUPLICATE OBJECT FOUND"
109
- break
110
- fi
111
- done &&
112
- test -z "$found_duplicate_object"
87
+ test_has_duplicate_object false
113
88
'
114
89
115
90
test_expect_success ' packed obs in alt ODB are repacked even when local repo is packless' '
0 commit comments