]> Kevux Git Server - rit/commit
describe: fix --exclude, --match with --contains and --all
authorJacob Keller <jacob.keller@gmail.com>
Mon, 1 Jun 2026 23:36:08 +0000 (16:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Jun 2026 00:31:12 +0000 (09:31 +0900)
commit1891707d1b8bb0ac3c47343e881fcf28ec69457a
tree74aad3bc5b6d829ac92c11da8858f5b200494e6d
parenta89346e34a937f001e5d397ee62224e3e9852040
describe: fix --exclude, --match with --contains and --all

git describe --contains acts as a wrapper around git name-rev. When
operating with --contains and --all, the --match and --exclude patterns
are not properly forwarded to name-rev as --exclude and --refs options.

This results in the command silently discarding match and exclude
requests from the user when operating in --all mode.

We could check and die() if the user provides --contains, --all, and
--match/--exclude. However, its also straight forward to just pass the
filters down to git name-rev.

Notice that the documentation for --match and --exclude mention the
--all mode. It explains that they operate on refs with the prefix
refs/tags, and additionally refs/heads and refs/remotes when using
--all.

Fix the describe logic to pass the patterns down with the appropriate
prefixes when --all is provided. This fixes the support to match the
documented behavior.

Add tests to check that this works as expected.

Reported-by: Tuomas Ahola <taahol@utu.fi>
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
t/t6120-describe.sh