Message ID | c2e5a0b3a50237f3b7f5ceb5d05faa83fd41de68.1659122979.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | log: create tighter default decoration filter | expand |
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > if (prefix) { > strbuf_addstr(&normalized_pattern, prefix); > - } > - else if (!starts_with(pattern, "refs/")) > + } else if (!starts_with(pattern, "refs/") && > + strcmp(pattern, "HEAD")) Perhaps leave a needswork comment to remind us to later consider covering all the pseudorefs like MERGE_HEAD, CHERRY_PICK_HEAD etc.? > strbuf_addstr(&normalized_pattern, "refs/"); Style: If you plan to add more code to the bodies of this if/elseif, then have {} around all arms. Otherwise, let's lose the {} around the body of "if (prefix)".
On 8/3/2022 2:03 AM, Junio C Hamano wrote: > "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > >> if (prefix) { >> strbuf_addstr(&normalized_pattern, prefix); >> - } >> - else if (!starts_with(pattern, "refs/")) >> + } else if (!starts_with(pattern, "refs/") && >> + strcmp(pattern, "HEAD")) > > Perhaps leave a needswork comment to remind us to later consider > covering all the pseudorefs like MERGE_HEAD, CHERRY_PICK_HEAD etc.? A comment is a good idea. We should leave it for later because it would make a visible change from the user's perspective. >> strbuf_addstr(&normalized_pattern, "refs/"); > > Style: > > If you plan to add more code to the bodies of this if/elseif, then > have {} around all arms. Otherwise, let's lose the {} around the > body of "if (prefix)". Yes, thanks for the close eyes. Thanks, -Stolee
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/"); strbuf_addstr(&normalized_pattern, pattern); strbuf_strip_suffix(&normalized_pattern, "/"); diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 6e663525582..6b7d8e269f7 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -1025,6 +1025,12 @@ test_expect_success 'decorate-refs and simplify-by-decoration without output' ' test_cmp expect actual ' +test_expect_success 'decorate-refs-exclude HEAD' ' + git log --decorate=full --oneline \ + --decorate-refs-exclude="HEAD" >actual && + ! grep HEAD actual +' + test_expect_success 'log.decorate config parsing' ' git log --oneline --decorate=full >expect.full && git log --oneline --decorate=short >expect.short &&