Commit e6c1173dcf57c322cbb74af339c615c983c190f3

Stefan Sperling 2020-03-18T16:13:46

document why deltas will usually be resolved within a single loop iteration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index 650dd1e..058e504 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -706,6 +706,13 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmpfile,
 	pass++;
 	while (nvalid != nobj) {
 		int n = 0;
+		/*
+		 * This loop will only run once unless the pack file
+		 * contains ref deltas which refer to objects located
+		 * later in the pack file, which is unusual.
+		 * Offset deltas can always be resolved in one pass
+		 * unless the packfile is corrupt.
+		 */
 		for (i = 0; i < nobj; i++) {
 			obj = &objects[i];
 			if (obj->type != GOT_OBJ_TYPE_REF_DELTA &&