Skip to content

Commit d8b6868

Browse files
peffgitster
authored andcommitted
for-each-ref: load config earlier
In most commands we load config before parsing command line options, since it lets the latter override the former with a simple variable assignment. In the case of for-each-ref, though, we do it in the reverse order. This is OK with the current code, since there's no interaction between the config and command-line options. However, as the ref-filter code starts to care about config during verify_ref_format(), we'll want to make sure the config is loaded. Let's bump the config to the usual spot near the top of the function. We can drop the comment there; it's impossible to keep a "why we load the config" comment like this up to date with every config option we might be interested in. And indeed, it's already stale; we'd care about core.abbrev, for instance, when %(objectname:short) is used. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 136c8c8 commit d8b6868

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

builtin/for-each-ref.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
5454

5555
format.format = "%(objectname) %(objecttype)\t%(refname)";
5656

57+
git_config(git_default_config, NULL);
58+
5759
parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);
5860
if (maxcount < 0) {
5961
error("invalid --count argument: `%d'", maxcount);
@@ -71,9 +73,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
7173
sorting->ignore_case = icase;
7274
filter.ignore_case = icase;
7375

74-
/* for warn_ambiguous_refs */
75-
git_config(git_default_config, NULL);
76-
7776
filter.name_patterns = argv;
7877
filter.match_as_path = 1;
7978
filter_refs(&array, &filter, FILTER_REFS_ALL | FILTER_REFS_INCLUDE_BROKEN);

0 commit comments

Comments
 (0)