From: Junio C Hamano Date: Mon, 26 Sep 2022 21:55:39 GMT Subject: Re: [PATCH v3 1/3] maintenance: add 'unregister --force' Message-ID: In-Reply-To: <8a8bffaec89e55da0c5bcac2f04331e0d4e69790.1664218087.git.gitgitgadget@gmail.com> "Derrick Stolee via GitGitGadget" writes: > @@ -1538,11 +1546,23 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi > usage_with_options(builtin_maintenance_unregister_usage, > options); > > - config_unset.git_cmd = 1; > - strvec_pushl(&config_unset.args, "config", "--global", "--unset", > - "--fixed-value", "maintenance.repo", maintpath, NULL); > + for_each_string_list_item(item, list) { > + if (!strcmp(maintpath, item->string)) { > + found = 1; > + break; > + } > + } Just out of curiosity, I ran this in a fresh repository and got a segfault. An attached patch obviously fixes it, but I am wondering if a better "fix" is to teach for_each_string_list_item() that it is perfectly reasonable to see a NULL passed to it as the list, which is a mere special case that the caller has a string list with 0 items on it. Thoughts? Thanks. diff --git a/builtin/gc.c b/builtin/gc.c index 4c59235950..67f41fad4b 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1549,6 +1549,7 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi usage_with_options(builtin_maintenance_unregister_usage, options); + if (list) for_each_string_list_item(item, list) { if (!strcmp(maintpath, item->string)) { found = 1; -- 2.38.0-rc1-123-g02867222b8