]> git.ipfire.org Git - thirdparty/git.git/commit
refs: fix ref storage format for submodule ref stores
authorPatrick Steinhardt <ps@pks.im>
Thu, 8 Aug 2024 07:35:42 +0000 (09:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Aug 2024 16:22:21 +0000 (09:22 -0700)
commitfb99dded3123cef99aca6caded90251809f300e5
tree34c00460a37bd358ed2640f2197316a94b9d9946
parent69814846aba19f864e8140c2de982ea345f4ce1b
refs: fix ref storage format for submodule ref stores

When opening a submodule ref storage we accidentally use the ref storage
format of the owning repository, not of the submodule repository. As
submodules may have a different storage format than their parent repo
this can lead to bugs when trying to access the submodule ref storage
from the parent repository.

One such bug was reported when performing a recursive pull with mixed
ref stores, which fails with:

    $ git pull --recursive
    fatal: Unable to find current revision in submodule path 'path/to/sub'

The same issue occurs when adding a repository contained in the working
tree with a different ref storage format via `git submodule add`.

Fix the bug by using the submodule repository's ref storage format
instead and add some tests. Note that the test for `git submodule
status` was included as a precaution, only. The command worked alright
even without the bugfix.

Reported-by: Jeppe Øland <joland@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
t/t7424-submodule-mixed-ref-formats.sh