git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* Checking Out Branches Containing Submodules With update=none and submodule.recurse=true Fails With fatal:not a git repository
@ 2020-03-25  4:19 daniel mclean
  0 siblings, 0 replies; only message in thread
From: daniel mclean @ 2020-03-25  4:19 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25  4:19 Checking Out Branches Containing Submodules With update=none and submodule.recurse=true Fails With fatal:not a git repository daniel mclean

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git