Commit eca70f98448556db333b7c61d37122488b572422

Stefan Sperling 2021-09-03T09:51:31

fix 'got send' adding too many objects to the pack file in some cases Load server-side tags before loading local commits. Otherwise objects which are reachable via server-side tags will not be filtered out.

diff --git a/lib/pack_create.c b/lib/pack_create.c
index 1455b6d..4ab44ac 100644
--- a/lib/pack_create.c
+++ b/lib/pack_create.c
@@ -862,19 +862,6 @@ read_meta(struct got_pack_meta ***meta, int *nmeta,
 		}
 	}
 
-	for (i = 0; i < nobj; i++) {
-		err = load_commit(&v, idset, ids[i], repo,
-		    loose_obj_only, cancel_cb, cancel_arg);
-		if (err)
-			goto done;
-		if (progress_cb) {
-			err = progress_cb(progress_arg, 0L, nours,
-			    v.nmeta, 0, 0);
-			if (err)
-				goto done;
-		}
-	}
-
 	for (i = 0; i < ntheirs; i++) {
 		struct got_object_id *id = theirs[i];
 		int *cached_type;
@@ -901,6 +888,19 @@ read_meta(struct got_pack_meta ***meta, int *nmeta,
 		}
 	}
 
+	for (i = 0; i < nobj; i++) {
+		err = load_commit(&v, idset, ids[i], repo,
+		    loose_obj_only, cancel_cb, cancel_arg);
+		if (err)
+			goto done;
+		if (progress_cb) {
+			err = progress_cb(progress_arg, 0L, nours,
+			    v.nmeta, 0, 0);
+			if (err)
+				goto done;
+		}
+	}
+
 	for (i = 0; i < nours; i++) {
 		struct got_object_id *id = ours[i];
 		int *cached_type;