string-list: report programming error with BUG

Passing a string list that has .strdup_strings bit unset to string_list_split(), or one that has .strdup_strings bit set to string_list_split_in_place(), is a programmer error. Do not use die() to abort the execution. Use BUG() instead. As a developer-facing message, the message string itself should be a lot more concise, but let's keep the original one for now. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 1, 2025 at 15:04 UTC 4f9c8d896397a1748132060d3465e8573c861633
1 file changed +2 -2
string-list.c
+2 -2
@@ -283,7 +283,7 @@ int string_list_split(struct string_list *list, const char *string,
283 const char *p = string, *end;
284
285 if (!list->strdup_strings)
286 - die("internal error in string_list_split(): "
286 + BUG("internal error in string_list_split(): "
287 "list->strdup_strings must be set");
288 for (;;) {
289 count++;
@@ -309,7 +309,7 @@ int string_list_split_in_place(struct string_list *list, char *string,
309 char *p = string, *end;
310
311 if (list->strdup_strings)
312 - die("internal error in string_list_split_in_place(): "
312 + BUG("internal error in string_list_split_in_place(): "
313 "list->strdup_strings must not be set");
314 for (;;) {
315 count++;