From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: issue with git submodules and a clone.defaultRemoteName different than origin?
Date: Tue, 03 Jun 2025 16:42:34 -0700 [thread overview]
Message-ID: <xmqq1ps0gzo5.fsf@gitster.g> (raw)
In-Reply-To: <4f638125-39e0-43a1-9c58-35c2d433042f@intel.com> (Jacob Keller's message of "Tue, 3 Jun 2025 16:06:27 -0700")
Jacob Keller <jacob.e.keller@intel.com> writes:
>> fatal: 'origin' does not appear to be a git repository
>> fatal: Could not read from remote repository.
>> ...
> This appears to be due to the builtin/submodule--helper hard coding
> "origin" in "repo_get_default_remote".
>
> I am unsure what the best way to fix this is. I could have the function
> read the clone.defaultRemoteName, or I could have it check if there is
> only one remote then use that.. or maybe add a new submodule remote name
> option?
Is it is the nickname of the default remote that corresponds to
'origin' in other/most peoples' set-up you are using for your
submodules that is causing you? And because you have
clone.defaultRemoteName configured either in the superproject's
.git/config or your personal ~/.gitconfig, when you activate
submodules, the "git clone" used to populate your submodule
directory from elsewhere would use that custom name?
What I am trying to figure out by thinking aloud is if there a place
where that custom name name is recorded anywhere in the submodule
repository (or superproject, but I somehow doubt it).
The clone.defaultRemoteName configuration variable can be overriden
from the command line of "git clone", and even if the process to
activate a submodule does not let you pass the "--origin", you could
have updated your clone.defaultRemoteName, so the current value of
the configuration variable is pretty much useless.
Your "if there is only a single remote" would probably be a better
way. The only reason you are having trouble, if I am reading the
repo_get_default_remote(), is because you are on a detached HEAD.
Do we know where that HEAD was detached from, perhaps from the
reflog? If we are on a concrete branch, there already is a logic to
figure out what branch from what remote it integrates with, and that
would give you the most reliable answer.
> Thoughts on what the best solution is here?
>
> I'm thinking the following:
>
> 1) check if there is only one remote, then use that
> 2) check clone.defaultRemoteName and use that otherwise
> 3) fall back to origin otherwise?
I'd insert 1.5 to figure out where your detached HEAD came from and
use that as if you are on that branch. That is the source of the
problem, right?
> Perhaps we could insert a step 0 where we add a config option which will
> have submodule clones use the given remote name + use that as the
> default when in detached head state?
Going forward, it would of course be the most reliable if we wrote a
distinct configuration variable in submodule repository when we
activate it, i.e. when "git submodule update --init" clones, it can
record the nickname that was used, so that none of the 1-3) above
methods have to be used to guess what the name is.
Or, perhaps we can update "git submodule update --init" so that when
it clones, it ignores clone.defaultRemoteName configuration, so that
this codepath always can rely on the name being 'origin'. If you
are always accessing the submodule through the toplevel superproject,
the name used in the submodule does not make a difference, no?
next prev parent reply other threads:[~2025-06-03 23:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 23:06 issue with git submodules and a clone.defaultRemoteName different than origin? Jacob Keller
2025-06-03 23:42 ` Junio C Hamano [this message]
2025-06-04 17:18 ` Jacob Keller
2025-06-06 21:29 ` Jacob Keller
2025-06-06 23:32 ` Junio C Hamano
2025-06-07 5:43 ` Patrick Steinhardt
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=xmqq1ps0gzo5.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jacob.e.keller@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).