Skip to content

Commit 0d50556

Browse files
committed
Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0: verify-pack -v: do not report "chain length 0" t5510: harden the way verify-pack is used
2 parents 4258c21 + 262b04f commit 0d50556

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

builtin-verify-pack.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
static void show_pack_info(struct packed_git *p)
99
{
10-
uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
10+
uint32_t nr_objects, i;
11+
int cnt;
12+
unsigned long chain_histogram[MAX_CHAIN+1], baseobjects;
1113

1214
nr_objects = p->num_objects;
1315
memset(chain_histogram, 0, sizeof(chain_histogram));
16+
baseobjects = 0;
1417

1518
for (i = 0; i < nr_objects; i++) {
1619
const unsigned char *sha1;
@@ -29,9 +32,11 @@ static void show_pack_info(struct packed_git *p)
2932
&delta_chain_length,
3033
base_sha1);
3134
printf("%s ", sha1_to_hex(sha1));
32-
if (!delta_chain_length)
35+
if (!delta_chain_length) {
3336
printf("%-6s %lu %lu %"PRIuMAX"\n",
3437
type, size, store_size, (uintmax_t)offset);
38+
baseobjects++;
39+
}
3540
else {
3641
printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
3742
type, size, store_size, (uintmax_t)offset,
@@ -43,15 +48,21 @@ static void show_pack_info(struct packed_git *p)
4348
}
4449
}
4550

46-
for (i = 0; i <= MAX_CHAIN; i++) {
47-
if (!chain_histogram[i])
51+
if (baseobjects)
52+
printf("non delta: %lu object%s\n",
53+
baseobjects, baseobjects > 1 ? "s" : "");
54+
55+
for (cnt = 1; cnt <= MAX_CHAIN; cnt++) {
56+
if (!chain_histogram[cnt])
4857
continue;
49-
printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
50-
chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
58+
printf("chain length = %d: %lu object%s\n", cnt,
59+
chain_histogram[cnt],
60+
chain_histogram[cnt] > 1 ? "s" : "");
5161
}
5262
if (chain_histogram[0])
53-
printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
54-
chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
63+
printf("chain length > %d: %lu object%s\n", MAX_CHAIN,
64+
chain_histogram[0],
65+
chain_histogram[0] > 1 ? "s" : "");
5566
}
5667

5768
static int verify_one_pack(const char *path, int verbose)

t/t5510-fetch.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ test_description='Per branch config variables affects "git fetch".
99

1010
D=`pwd`
1111

12+
test_bundle_object_count () {
13+
git verify-pack -v "$1" >verify.out &&
14+
test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l)
15+
}
16+
1217
test_expect_success setup '
1318
echo >file original &&
1419
git add file &&
@@ -146,6 +151,7 @@ test_expect_success 'unbundle 1' '
146151
test_must_fail git fetch "$D/bundle1" master:master
147152
'
148153

154+
149155
test_expect_success 'bundle 1 has only 3 files ' '
150156
cd "$D" &&
151157
(
@@ -156,8 +162,7 @@ test_expect_success 'bundle 1 has only 3 files ' '
156162
cat
157163
) <bundle1 >bundle.pack &&
158164
git index-pack bundle.pack &&
159-
verify=$(git verify-pack -v bundle.pack) &&
160-
test 4 = $(echo "$verify" | wc -l)
165+
test_bundle_object_count bundle.pack 3
161166
'
162167

163168
test_expect_success 'unbundle 2' '
@@ -180,7 +185,7 @@ test_expect_success 'bundle does not prerequisite objects' '
180185
cat
181186
) <bundle3 >bundle.pack &&
182187
git index-pack bundle.pack &&
183-
test 4 = $(git verify-pack -v bundle.pack | wc -l)
188+
test_bundle_object_count bundle.pack 3
184189
'
185190

186191
test_expect_success 'bundle should be able to create a full history' '

0 commit comments

Comments
 (0)