Commits

Anonymous committed 0d50556 Merge

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

Comments (0)

Files changed (2)

builtin-verify-pack.c

 
 static void show_pack_info(struct packed_git *p)
 {
-	uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
+	uint32_t nr_objects, i;
+	int cnt;
+	unsigned long chain_histogram[MAX_CHAIN+1], baseobjects;
 
 	nr_objects = p->num_objects;
 	memset(chain_histogram, 0, sizeof(chain_histogram));
+	baseobjects = 0;
 
 	for (i = 0; i < nr_objects; i++) {
 		const unsigned char *sha1;
 						 &delta_chain_length,
 						 base_sha1);
 		printf("%s ", sha1_to_hex(sha1));
-		if (!delta_chain_length)
+		if (!delta_chain_length) {
 			printf("%-6s %lu %lu %"PRIuMAX"\n",
 			       type, size, store_size, (uintmax_t)offset);
+			baseobjects++;
+		}
 		else {
 			printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
 			       type, size, store_size, (uintmax_t)offset,
 		}
 	}
 
-	for (i = 0; i <= MAX_CHAIN; i++) {
-		if (!chain_histogram[i])
+	if (baseobjects)
+		printf("non delta: %lu object%s\n",
+		       baseobjects, baseobjects > 1 ? "s" : "");
+
+	for (cnt = 1; cnt <= MAX_CHAIN; cnt++) {
+		if (!chain_histogram[cnt])
 			continue;
-		printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
-		       chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
+		printf("chain length = %d: %lu object%s\n", cnt,
+		       chain_histogram[cnt],
+		       chain_histogram[cnt] > 1 ? "s" : "");
 	}
 	if (chain_histogram[0])
-		printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
-		       chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
+		printf("chain length > %d: %lu object%s\n", MAX_CHAIN,
+		       chain_histogram[0],
+		       chain_histogram[0] > 1 ? "s" : "");
 }
 
 static int verify_one_pack(const char *path, int verbose)
 
 D=`pwd`
 
+test_bundle_object_count () {
+	git verify-pack -v "$1" >verify.out &&
+	test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l)
+}
+
 test_expect_success setup '
 	echo >file original &&
 	git add file &&
 	test_must_fail git fetch "$D/bundle1" master:master
 '
 
+
 test_expect_success 'bundle 1 has only 3 files ' '
 	cd "$D" &&
 	(
 		cat
 	) <bundle1 >bundle.pack &&
 	git index-pack bundle.pack &&
-	verify=$(git verify-pack -v bundle.pack) &&
-	test 4 = $(echo "$verify" | wc -l)
+	test_bundle_object_count bundle.pack 3
 '
 
 test_expect_success 'unbundle 2' '
 		cat
 	) <bundle3 >bundle.pack &&
 	git index-pack bundle.pack &&
-	test 4 = $(git verify-pack -v bundle.pack | wc -l)
+	test_bundle_object_count bundle.pack 3
 '
 
 test_expect_success 'bundle should be able to create a full history' '
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.