]> git.ipfire.org Git - thirdparty/git.git/commit
attr: fix BUG() when parsing attrs outside of repo
authorPatrick Steinhardt <ps@pks.im>
Tue, 7 May 2024 04:53:05 +0000 (06:53 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2024 05:50:49 +0000 (22:50 -0700)
commit813f17fd6bd9289185a50f1d1179393bd1339b9b
treea13ed7ac2aaed959edcab80710fc575ec7555832
parentbbb82f8dc88aee588a35615fdb10862f3b41e16c
attr: fix BUG() when parsing attrs outside of repo

If either the `--attr-source` option or the `GIT_ATTR_SOURCE` envvar are
set, then `compute_default_attr_source()` will try to look up the value
as a treeish. It is possible to hit that function while outside of a Git
repository though, for example when using `git grep --no-index`. In that
case, Git will hit a bug because we try to look up the main ref store
outside of a repository.

Handle the case gracefully and detect when we try to look up an attr
source without a repository.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr.c
t/t0003-attributes.sh