From: Stanislav Aleksandrov <lightofmysoul@gmail.com>
To: jacob.keller@gmail.com
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Adrian Ratiu <adrian.ratiu@collabora.com>,
Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [RFC PATCH] submodule: make '^/' work like '../' but with an absolute path
Date: Sun, 25 Oct 2026 21:25:17 +0000 [thread overview]
Message-ID: <20261025212517.479922-1-lightofmysoul@gmail.com> (raw)
In-Reply-To: <CA+P7+xoSd2rsHpw+n5vCrcqXRibG6zH+SKCsVXA0OW-VZN_+=g@mail.gmail.com>
On Sun, Oct 25, 2026 at 12:42 PM Jacob Keller
<jacob.keller@gmail.com> wrote:
> On Tue, Sep 29, 2026 at 11:51 AM Stanislav Aleksandrov
> <lightofmysoul@gmail.com> wrote:
>> - Why not url.<base>.insteadOf? It has to be set up on every clone;
>> .gitmodules cannot carry it.
>
> Could .gitmodules be extended to carry this information?
Not as a rewrite rule. A rule maps one fixed prefix to another, and
.gitmodules is the same for everyone, so it can't send one person over
https and another over ssh with their own host alias. What differs per
clone is the superproject's remote URL, and that's what "../" and "^/"
resolve against.
We could add a separate "same server as the superproject" key next to
an absolute URL and then Git would ignore the host written in that
URL, but that would be really confusing.
>> - Compatibility: a local "^/..." path needs a "^" directory in the
>> superproject and protocol.file.allow=always, and "git submodule
>> add" refuses it.
>
> What do you mean here by "refuses it" Is this character already
> refused? I.e. "^" isn't considered a valid directory, which is why its
> suitable for converting to a special meaning?
No, "^" is a valid directory name, and today "^/org/lib.git" means a
repository in a "^" directory of the superproject. By "refuses" I
meant that "git submodule add" rejects it, as it does "foo/lib.git":
fatal: repo URL: '^/org/lib.git' must be absolute or begin with ./|../
So such a URL has to be written into .gitmodules by hand or with "git
submodule set-url", and since 2.38.1 it can't be cloned without
protocol.file.allow=always. It is possible, just very unlikely.
> The ultimate goal would be to allow users to specify what protocol
> they want to operate on.
Relative URLs already do that: a superproject cloned over ssh gets its
"../" submodules over ssh too. The problem is that they also follow
where the superproject lives.
> I guess "insteadOf" even in the .gitmodules wouldn't work because you
> wouldn't want to apply that to everyone. The issue seems to be caused
> because of the URLs on Gitlab changing such that relative paths don't
> work anymore?
The URLs don't change. Forks are the problem. A fork lives in another
namespace, and on GitLab often at a different depth, because groups
can be nested.
> Does doing something like "../../" work to allow the subproject to
> find the root from a relative path? Or does the current logic not
> support multiple ".."?
Multiple ".." work, but the count has to match how deep the
superproject is. Let's say the upstream is https://gitlab.com/org/super.git
and lib is https://gitlab.com/org/lib.git:
- "../lib.git" gives me/lib.git for a fork at me/super.git, which
only exists if lib was forked too.
- "../../org/lib.git" works for me/super.git, but gives
group/org/lib.git for a fork at group/team/super.git.
- "../../../org/lib.git" works for group/team/super.git, but for
me/super.git it climbs past the root and eats the host:
https://org/lib.git.
"^/org/lib.git" gives https://gitlab.com/org/lib.git for all of them,
or git@gitlab.com:org/lib.git if the superproject was cloned over ssh.
On GitHub every repository is two levels deep, so "../../org/lib.git"
works for everyone. GitLab and plain SSH servers have no fixed
depth.
next prev parent reply other threads:[~2026-10-25 21:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 18:51 [RFC PATCH] submodule: make '^/' work like '../' but with an absolute path Stanislav Aleksandrov
2026-10-25 19:42 ` Jacob Keller
2026-10-25 21:25 ` Stanislav Aleksandrov [this message]
2026-10-25 23:11 ` Jacob Keller
2026-10-27 17:39 ` Junio C Hamano
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=20261025212517.479922-1-lightofmysoul@gmail.com \
--to=lightofmysoul@gmail.com \
--cc=adrian.ratiu@collabora.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/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