From: Pablo Sabater Date: Fri, 13 Mar 2026 11:59:31 GMT Subject: Re: [PATCH] gc: add git maintenance list command Message-ID: <20260313115932.15259-1-pabloosabaterr@gmail.com> In-Reply-To: > char *config_file = NULL; > if (config_file) { > git_configset_init(&cs); > git_configset_add_file(&cs, config_file); > if (git_configset_get_string_multi(&cs, key, &list)) { > /* No repositories registered in custom config */ > git_configset_clear(&cs); > return 0; > } > } else { > global_config_file = git_global_config(); > if (!global_config_file) > die(_("$HOME not set")); > git_configset_init(&cs); > git_configset_add_file(&cs, global_config_file); > if (git_configset_get_string_multi(&cs, key, &list)) { > /* No repositories registered in global config */ > free(global_config_file); > git_configset_clear(&cs); > return 0; > } > } Here the branches look too similar, after the third line at the else it becomes exactly the same. If you notice, global_config_file is initialized as NULL then in case of !config_file, its value comes from git_global_config(). Anyways, there's no need to separate the free logic because both NULL and git_global_config() can be freed. you can avoid this by extracting the diferent logic from the else if (!config_file) { config_file = git_global_config(); if (!config_file) die(_("$HOME not set")); global_config_file = config_file; } and then the rest of the code is common for both cases git_configset_init(&cs); git_configset_add_file(&cs, config_file); if (git_configset_get_string_multi(&cs, key, &list)) { free(global_config_file); git_configset_clear(&cs); return 0; }