From: daniel mclean <maczor@gmail.com>
To: git@vger.kernel.org
Subject: Checking Out Branches Containing Submodules With update=none and submodule.recurse=true Fails With fatal:not a git repository
Date: Wed, 25 Mar 2020 14:19:26 +1000 [thread overview]
Message-ID: <CABVQXt5E-R22G62W-tQieA7XiZKZiOA8Hp2xewYhwwOS8wFh0Q@mail.gmail.com> (raw)
Hello git developers,
Firstly thanks for a great tool!
I have run into an issue that it would be good to get your advice on.
I have a git repository with multiple submodules. A few of these
submodules are configured with update=none so that they point to a
specific commit but so that clone operations and submodule update
operations don't retrieve their contents.
When working with this repository and trying to change branches, git
is reporting a fatal error when changing branches. This can be worked
around by deinit'ing the submodules before switching branches but that
doesn't seem like it should be necessary.
The reproduction steps are to:
- Clone the repo
- Checkout a branch containing submodules that are set with
update=none (git checkout branch-name)
- Update and init submodules (git submodule update --init)
- Attempt to switch to a different branch (git checkout other-branch)
At this point git will report an error at the first submodule with update=none:
fatal: not a git repository: ../.git/modules/no-update-submodule
fatal: could not reset submodule index
After doing some sleuthing it seems that this is because when
update=none the submodule repository is not cloned to
.git/module/<module name>, however when attempting to change branches
using a checkout, git then stumbles since it expects the repository to
be there.
This seems obvious when run with GIT_TRACE=1, git fails when it
attempts to run the read-tree command:
19:20:18.129343 run-command.c:663 trace: run_command: cd
no-update-submodule; unset GIT_PREFIX; GIT_DIR=.git git
--super-prefix= no-update-submodule/ read-tree -u --reset
4b825dc642cb6eb9a060e54bf8d69288fbee4904
fatal: not a git repository: ../.git/modules/no-update-submodule
fatal: could not reset submodule index
If my understanding of how update=none for a submodule and git is
correct, then it seems like it shouldn't be trying to do this since it
should know that the repository isn't there (update=none after all).
This behaviour occurs when I have submodule.recurse set to true,
however interestingly when I set it to false I don't run into this
issue.
So it seems like these two directives are providing mixed messages in
a sense, one says don't clone the submodule repo and the other says
look into the submodule repo and try to find more submodules.
I've tried the 2.20 version of git that comes prepackaged with my OS
and built git 2.26 from source with the same outcome. I'm running on
Debian stretch on x64 in case that matters.
I'm happy to pursue trying to suggest a fix for this, but am new to
the git codebase and so would appreciate some feedback on whether this
is in fact an issue and some advice on how to best approach a
solution.
Thanks
Daniel
next reply other threads:[~2020-03-25 4:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 4:19 daniel mclean [this message]
2020-10-07 21:29 ` Checking Out Branches Containing Submodules With update=none and submodule.recurse=true Fails With fatal:not a git repository Philippe Blain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABVQXt5E-R22G62W-tQieA7XiZKZiOA8Hp2xewYhwwOS8wFh0Q@mail.gmail.com \
--to=maczor@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.