diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:44 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-05 09:44:44 -0800 |
commit | d037212d973351ced4a3f0bb0705575bee4f8566 (patch) | |
tree | 34c0fc73c87850a10df780c5c6a4ecc446be7b6b /builtin | |
parent | 661f3797916d2bc3bd967a9dc9e6e464d5343758 (diff) | |
parent | 33d15b54358d8ec7fc0bd70062ddd1116402c8fe (diff) | |
download | git-d037212d973351ced4a3f0bb0705575bee4f8566.tar.gz |
Merge branch 'kn/for-all-refs'
"git for-each-ref" learned "--include-root-refs" option to show
even the stuff outside the 'refs/' hierarchy.
* kn/for-all-refs:
for-each-ref: add new option to include root refs
ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
refs: introduce `refs_for_each_include_root_refs()`
refs: extract out `loose_fill_ref_dir_regular_file()`
refs: introduce `is_pseudoref()` and `is_headref()`
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 3885a9c28e..919282e12a 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -20,10 +20,10 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) { struct ref_sorting *sorting; struct string_list sorting_options = STRING_LIST_INIT_DUP; - int icase = 0; + int icase = 0, include_root_refs = 0, from_stdin = 0; struct ref_filter filter = REF_FILTER_INIT; struct ref_format format = REF_FORMAT_INIT; - int from_stdin = 0; + unsigned int flags = FILTER_REFS_REGULAR; struct strvec vec = STRVEC_INIT; struct option opts[] = { @@ -53,6 +53,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) OPT_NO_CONTAINS(&filter.no_commit, N_("print only refs which don't contain the commit")), OPT_BOOL(0, "ignore-case", &icase, N_("sorting and filtering are case insensitive")), OPT_BOOL(0, "stdin", &from_stdin, N_("read reference patterns from stdin")), + OPT_BOOL(0, "include-root-refs", &include_root_refs, N_("also include HEAD ref and pseudorefs")), OPT_END(), }; @@ -96,8 +97,11 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) filter.name_patterns = argv; } + if (include_root_refs) + flags |= FILTER_REFS_ROOT_REFS; + filter.match_as_path = 1; - filter_and_format_refs(&filter, FILTER_REFS_ALL, sorting, &format); + filter_and_format_refs(&filter, flags, sorting, &format); ref_filter_clear(&filter); ref_sorting_release(sorting); |