@@ -63,8 +63,6 @@ int cmd_for_each_ref(int argc,
format.format = "%(objectname) %(objecttype)\t%(refname)";
- git_config(git_default_config, NULL);
-
/* Set default (refname) sorting */
string_list_append(&sorting_options, "refname");
@@ -80,6 +78,7 @@ int cmd_for_each_ref(int argc,
if (verify_ref_format(&format))
usage_with_options(for_each_ref_usage, opts);
+ git_config(git_default_config, NULL);
sorting = ref_sorting_options(&sorting_options);
ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
filter.ignore_case = icase;
Move `git_config()` call after `usage_with_options()` to avoid NULL `repo` check. When "-h" is passed to builtins using the RUN_SETUP macro, `repo` passed by `run_builtin()` will be NULL. If we use the `repo` instead of the global `the_repository` variable. We will have to switch from `git_config()` to `repo_config()` which takes in `repo`. We must check for NULL `repo` if `repo_config()` comes before `usage_with_options()`. Moving `git_config()` after `usage_with_options()` eliminates this need, as `usage_with_options()` exit before calling `repo_config()`. This will be useful in the following patch which remove `the_repository` global variable in favor of the `repo` passed by `run_builtin()`. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com> --- builtin/for-each-ref.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)