On Tue, Jul 26 2022, Derrick Stolee via GitGitGadget wrote: > From: Derrick Stolee <derrickstolee@xxxxxxxxxx> > > The normalize_glob_ref() method was introduced in 65516f586b693 (log: > add option to choose which refs to decorate, 2017-11-21) to help with > decoration filters such as --decorate-refs=<filter> and > --decorate-refs-exclude=<filter>. The method has not been used anywhere > else. > > At the moment, it is impossible to specify HEAD as a decoration filter > since normalize_glob_ref() prepends "refs/" to the filter if it isn't > already there. > > Allow adding HEAD as a decoration filter by allowing the exact string > "HEAD" to not be prepended with "refs/". Add a test in t4202-log.sh that > would previously fail since the HEAD decoration would exist in the > output. > > It is sufficient to only cover "HEAD" here and not include other special > refs like REBASE_HEAD. This is because HEAD is the only ref outside of > refs/* that is added to the list of decorations. > > Signed-off-by: Derrick Stolee <derrickstolee@xxxxxxxxxx> > --- > refs.c | 4 ++-- > t/t4202-log.sh | 6 ++++++ > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/refs.c b/refs.c > index 90bcb271687..ec3134e4842 100644 > --- a/refs.c > +++ b/refs.c > @@ -457,8 +457,8 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix, > > if (prefix) { > strbuf_addstr(&normalized_pattern, prefix); > - } > - else if (!starts_with(pattern, "refs/")) > + } else if (!starts_with(pattern, "refs/") && > + strcmp(pattern, "HEAD")) > strbuf_addstr(&normalized_pattern, "refs/"); Arguably a digression for this series, but I think it would be very nice to have a pre-step where we'd create some pre-step to centrally declare these magical refs in some struct whose flags would cover these various cases. E.g. we have this hardcoded in should_autocreate_reflog(), in log-tree.c (which AFAICT is the reference to "HEAD" here), refs.c etc. etc.