]> git.ipfire.org Git - thirdparty/git.git/commit
wt-status: read HEAD and ORIG_HEAD via the refdb
authorPatrick Steinhardt <ps@pks.im>
Thu, 14 Dec 2023 13:36:58 +0000 (14:36 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 17:25:26 +0000 (09:25 -0800)
commit8f61321ccbdea20945a73446f24a6c380cb2c53b
tree904ac2f36de4c9c6b05725aae9ad55f803d19f75
parent1a87c842ece327d03d08096395969aca5e0a6996
wt-status: read HEAD and ORIG_HEAD via the refdb

We read both the HEAD and ORIG_HEAD references directly from the
filesystem in order to figure out whether we're currently splitting a
commit. If both of the following are true:

  - HEAD points to the same object as "rebase-merge/amend".

  - ORIG_HEAD points to the same object as "rebase-merge/orig-head".

Then we are currently splitting commits.

The current code only works by chance because we only have a single
reference backend implementation. Refactor it to instead read both refs
via the refdb layer so that we'll also be compatible with alternate
reference backends.

There are some subtleties involved here:

  - We pass `RESOLVE_REF_READING` so that a missing ref will cause
    `read_ref_full()` to return an error.

  - We pass `RESOLVE_REF_NO_RECURSE` so that we do not try to resolve
    symrefs. The old code didn't resolve symrefs either, and we only
    ever write object IDs into the refs in "rebase-merge/".

  - In the same spirit we verify that successfully-read refs are not
    symbolic refs.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c