Thread (32 messages) flat view 32 messages, 4 authors, 3h ago

Re: [PATCH 3/8] builtin/clone: refactor handling of "--reference{,-if-able}"

From: Toon Claes <hidden>
Date: 2026-08-28 14:52:20

Patrick Steinhardt [off-list ref] writes:
quoted hunk ↗ jump to hunk
diff --git a/builtin/clone.c b/builtin/clone.c
index 8c990ce0cc..8eae3ac7d9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -218,14 +220,20 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)
 	fclose(in);
 }
 
-static void setup_reference(void)
+static void collect_alternates(struct strvec *alternates)
 {
-	int required = 1;
-	for_each_string_list(&option_required_reference,
-			     add_one_reference, &required);
-	required = 0;
-	for_each_string_list(&option_optional_reference,
-			     add_one_reference, &required);
+	if (option_required_reference.nr || option_optional_reference.nr) {
I was about to ask why you're adding this guard, but it looks a lot more
clean with the next commit on top.
+		struct add_one_alternate_data data = {
+			.alternates = alternates,
+			.required = 1,
+		};
+
+		for_each_string_list(&option_required_reference,
+				     add_one_alternate, &data);
+		data.required = 0;
+		for_each_string_list(&option_optional_reference,
+				     add_one_alternate, &data);
+	}
 }
-- 
Laters,
Toon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help