git/Documentation/config
Patrick Steinhardt 7174098834 pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"
The "pack.preferBitmapTips" configuration allows the user to specify
which references should be preferred when generating bitmaps. This
option is typically expected to be set to a reference prefix, like for
example "refs/heads/".

It's not unreasonable though for a user to configure one specific
reference as preferred. But if they do, they'll hit a `BUG()`:

    $ git -c pack.preferBitmapTips=refs/heads/main repack -adb
    BUG: ../refs/iterator.c:366: attempt to trim too many characters
    error: pack-objects died of signal 6

The root cause for this bug is how we enumerate these references. We
call `refs_for_each_ref_in()`, which will:

  - Yield all references that have a user-specified prefix.

  - Trim each of these references so that the prefix is removed.

Typically, this function is called with a trailing slash, like
"refs/heads/", and in that case things work alright. But if the function
is called with the name of an existing reference then we'll try to trim
the full reference name, which would leave us with an empty name. And as
this would not really leave us with anything sensible, we call `BUG()`
instead of yielding this reference.

One could argue that this is a bug in `refs_for_each_ref_in()`. But the
question then becomes what the correct behaviour would be:

  - Do we want to skip exact matches? In our case we certainly don't
    want that, as the user has asked us to generate a bitmap for it.

  - Do we want to yield the reference with the empty refname? That would
    lead to a somewhat weird result.

Neither of these feel like viable options, so calling `BUG()` feels like
a sensible way out. The root cause ultimately is that we even try to
trim the whole refname in the first place. There are two possible ways
to fix this issue:

  - We can fix the bug by using `refs_for_each_fullref_in()` instead,
    which does not strip the prefix at all. Consequently, we would now
    start to accept all references that start with the configured
    prefix, including exact matches. So if we had "refs/heads/main", we
    would both match "refs/heads/main" and "refs/heads/main-branch".

  - Or we can fix the bug by appending a slash to the prefix if it
    doesn't already have one. This would mean that we only match
    ref hierarchies that start with this prefix.

While the first fix leaves the user with strictly _more_ configuration
options, we have already fixed a similar case in 10e8a9352b (refs.c:
stop matching non-directory prefixes in exclude patterns, 2025-03-06) by
using the second option. So for the sake of consistency, let's apply the
same fix here.

Clarify the documentation accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-02-19 10:41:18 -08:00
..
add.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
advice.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
alias.adoc Merge branch 'kh/you-still-use-whatchanged-fix' 2025-10-02 12:26:12 -07:00
am.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
apply.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
attr.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bitmap-pseudo-merge.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
blame.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
branch.adoc doc: improve formatting in branch section 2025-06-30 11:11:36 -07:00
browser.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bundle.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
checkout.adoc doc: convert git-checkout manpage to new style 2025-05-27 07:50:58 -07:00
clean.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
clone.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
color.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
column.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
commit.adoc doc: config: mention core.commentChar on commit.cleanup 2025-05-27 15:31:06 -07:00
commitgraph.adoc commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
completion.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
core.adoc Merge branch 'mh/doc-core-attributesfile' 2025-12-30 12:58:19 +09:00
credential.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
diff.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
difftool.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
extensions.adoc Merge branch 'ja/doc-markup-attached-paragraph-fix' 2025-10-13 22:00:35 -07:00
fastimport.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
feature.adoc setup: use "reftable" format when experimental features are enabled 2025-07-07 06:26:21 -07:00
fetch.adoc doc: convert git fetch to synopsis style 2025-11-19 15:00:37 -08:00
filter.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fmt-merge-msg.adoc doc: switch merge config description to new synopsis format 2025-05-27 07:51:00 -07:00
format.adoc whatchanged: remove when built with WITH_BREAKING_CHANGES 2025-05-12 15:30:12 -07:00
fsck.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fsmonitor--daemon.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gc.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gitcvs.adoc completion: make sed command that generates config-list.h portable. 2025-06-02 17:21:49 -07:00
gitweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gpg.adoc gpg-interface: expand gpg.program as a path 2025-07-14 10:07:02 -07:00
grep.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gui.adoc config: document 'gui.GCWarning' 2025-12-09 07:38:56 +09:00
guitool.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
help.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
http.adoc completion: make sed command that generates config-list.h portable. 2025-06-02 17:21:49 -07:00
i18n.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
imap.adoc imap-send: enable specifying the folder using the command line 2025-06-20 08:11:17 -07:00
includeif.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
index.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
init.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
instaweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
interactive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
log.adoc doc: git-log: fix description list 2025-08-08 09:14:46 -07:00
lsrefs.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailinfo.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailmap.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
maintenance.adoc builtin/maintenance: introduce "geometric" strategy 2025-10-24 13:42:45 -07:00
man.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
merge.adoc merge/pull: extend merge.stat configuration variable to cover --compact-summary 2025-06-13 11:54:14 -07:00
mergetool.adoc doc: config: replace backtick with apostrophe for possessive 2025-08-25 12:42:45 -07:00
notes.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
pack.adoc pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips" 2026-02-19 10:41:18 -08:00
pager.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pretty.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
promisor.adoc promisor-remote: allow a client to check fields 2025-09-08 10:30:55 -07:00
protocol.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pull.adoc pull: add pull.autoStash config option 2025-07-21 15:01:21 -07:00
push.adoc doc: convert git push to synopsis style 2025-11-19 15:00:45 -08:00
rebase.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
receive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
reftable.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
remote.adoc fetch: only respect followRemoteHEAD with configured refspecs 2025-03-18 12:21:25 -07:00
remotes.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
repack.adoc repack: exclude cruft pack(s) from the MIDX where possible 2025-06-23 15:41:38 -07:00
replay.adoc replay: add replay.refAction config option 2025-11-05 13:34:55 -08:00
rerere.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
revert.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
safe.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
sendemail.adoc send-email: enable copying emails to an IMAP folder without actually sending them 2025-08-12 08:59:36 -07:00
sequencer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
showbranch.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
sparse.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
splitindex.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
ssh.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
stash.adoc Merge branch 'dk/stash-apply-index' 2025-10-20 14:12:17 -07:00
status.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
submodule.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
tag.adoc doc: convert git tag to synopsis style 2025-10-05 16:09:03 -07:00
tar.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trace2.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trailer.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
transfer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadarchive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadpack.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
url.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
user.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
versionsort.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
web.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
worktree.adoc doc: convert git worktree to synopsis style 2025-10-05 16:09:03 -07:00