threads / discuss / 44878

patch, 4 partssubmodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

Subject: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

## tl;dr

8 messages between Jan 13, 2017 and Jan 25, 2017. Diffs are folded; open one to read it.

replies: 7people: 2as markdown or json

Stefan Beller· Jan 13, 2017, 18:30 UTC · lore

This question is about networking; the patch you originally replied to was strictly about local operations in the filesystem, which is quite a difference, so let's discuss it separately.

On Fri, Jan 13, 2017 at 9:56 AM, Brian J. Davis <bitminer@gmail.com> wrote:
Show 27 quoted lines
>
> In response to a post at:
>
> https://groups.google.com/forum/#!topic/git-users/BVLcKHhSUKo
>
> I was asked to post here to explain a potential problem with current modules
> implementation.  Apologies if I am posting in the wrong place... so good bad
> or otherwise here goes:
>
> +-------------------------------
> With:
>
> git push origin branchname
>
> or
>
> git push server2 branchname
>
> I can push or pull from multiple servers so no problem as git supports this.
>
> Now the problem with use of submodules
>
> submodules are listed:
>
> submodule.directory_to_
> checkout/proj1_dir.url=https://git.someserver1/git/proj1_dir
> <https://git.someserver1/git/proj1_dir>

Technically it is submodule.<name>.url instead of submodule.<path>.url. The name is usually the path initially, and once you move the submodule, only the path changes, the name is supposed to be constant and stay the same.

Show 5 quoted lines
>
>
> but if say I want to pull from some server 2 and do a
>
> git submodule update --init --recursive
That is why the "git submodule init" exists at all.
    git submodule init
    $EDIT .git/config # change submodule.<name>.url to server2
    git submodule update # that uses the adapted url and
    # creates the submodule repository.
    # From now on the submodule is on its own.
    cd <submodule> && git config --list
    # prints an "origin" remote and a lot more

For a better explanation, I started a documentation series, see https://github.com/gitster/git/commit/e2b51b9df618ceeff7c4ec044e20f5ce9a87241e

(It is not finished, but that is supposed to explain this exact pain point in the STATES section, feel free to point out missing things or what is hard to understand)

>
> what I would get is from someserver1 not someserver2 as there is no "origin"
> support for submodules.  Is this correct?  If so can origin support be added
> to submodules?
Can you explain more in detail what you mean by origin support?
Show 33 quoted lines
> +-------------------------------
>
> So above was post from google group.  Maybe above is enough to explain the
> problem that can result, but if not here is a discussion as to why this can
> be confusing resulting to pushing or pulling from the incorrect server.
>
> Lets say projects starts at origin on https://server0.org. Project is then
> brought in house to server https://indhouse.corp by developer A.
>
> Developer A then changes the submodule projects to point to indhouse and
> changes submodules in super project to point to indhouse so everything is
> great.
>
> Then Developer B clones from indhouse makes changes to submodule1 and
> submodule1 and pushes them to indhouse.  Dev A tells Dev B hey thoes changes
> are great why don't you push to public server0 so every one can get thoes
> changes.  Dev B then git push origin branch_name on submodule1 and push
> origin on submodule 2 and superproject.  And everything is great ... right?
>
> Yes by now those who know git know what dev B  forgot or more to the point
> what git does not support in a "clean" way.  For those who don't enter the
> life of dev C
>
> So dev C clones from server0 and performs a git submodule update --init
> --recursive.  Now Dev C is on the www and can't see indhouse.corp and ...
> kerpow... Dev B and Dev C just experienced one of the many SW mines on the
> battlefield.
>
> I ask that git devs first see if I am correct with this assessment as I
> could be wrong... maybe there is a way of doing this... and if not add a
> feature to git to handle submodules and multiple origins cleanly.... and yes
> beating dev B with rubber chicken might be a solution though I am looking
> for a slightly better option.
Yes this is a big point that we want to solve eventually.

When devA brought it inhouse, what they meant to do was this: "This superproject is actually from server0, but we want to work on it, which may have submodules diverge from server0 eventually. So if a submodule changed you need to get it from the inhouse server, otherwise fall back to the server0".

That way developerB can just make changes to some submodules and when devC clones they get the "correct" submodule.

A weak attempt to do this is to use *relative* submodule urls. When using relative urls, and then mirroring the supeproject inhouse, then Git will look for the submodules as well inhouse, but there is no such "or if not found look at the original superprojects origin", which means, you have to mirror all submodules.

And then about upstreaming changes. If you have a single repo (no submodules), you have to teach people to run "git remote add remote server0.org && git push upstream ...", but that you can do for each submodule. (This is tedious:/ but maybe ok; some submodules are free to sent things upstream whereas others are supersecret that you do not want to push upstream ever.)

So yeah maybe we want to have more power in the superprojects push operation
    (in the superproject) $ git push --recurse-submodules \
       --only-these-submodules=subA,subB \
       --submodule-to=upstream-as-configered-in-super-project
This is a lot of words but for explaining that is ok?

Thanks, Stefan

Brian J. Davis· Jan 15, 2017, 21:02 UTC · re: Stefan Beller · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On 1/13/2017 12:30 PM, Stefan Beller wrote:
> This question is about networking; the patch you originally replied to
> was strictly about local operations in the filesystem, which is quite
> a difference, so let's discuss it separately.

Yep ok look like you reclassified this and opened new topic which I hope I am responding to correctly now.

Show 31 quoted lines
> On Fri, Jan 13, 2017 at 9:56 AM, Brian J. Davis <bitminer@gmail.com> wrote:
>> In response to a post at:
>>
>> https://groups.google.com/forum/#!topic/git-users/BVLcKHhSUKo
>>
>> I was asked to post here to explain a potential problem with current modules
>> implementation.  Apologies if I am posting in the wrong place... so good bad
>> or otherwise here goes:
>>
>> +-------------------------------
>> With:
>>
>> git push origin branchname
>>
>> or
>>
>> git push server2 branchname
>>
>> I can push or pull from multiple servers so no problem as git supports this.
>>
>> Now the problem with use of submodules
>>
>> submodules are listed:
>>
>> submodule.directory_to_
>> checkout/proj1_dir.url=https://git.someserver1/git/proj1_dir
>> <https://git.someserver1/git/proj1_dir>
> Technically it is submodule.<name>.url instead of
> submodule.<path>.url. The name is usually the path initially, and once
> you move the submodule, only the path changes, the name is supposed to
> be constant and stay the same.

I am not certain what is meant by this. All I know is I can use my "directory_to_checkout" above to place in tree relative from root the project any where in the tree not already tracked by git. You state name instead of path, but it allows path correct? Either that or I have gone off reservation with my use of git for years now. Maybe this is a deviation from how it is documented/should work and how it actually works? It works great how I use it.

Show 22 quoted lines
>>
>> but if say I want to pull from some server 2 and do a
>>
>> git submodule update --init --recursive
> That is why the "git submodule init" exists at all.
>
>      git submodule init
>      $EDIT .git/config # change submodule.<name>.url to server2
>      git submodule update # that uses the adapted url and
>      # creates the submodule repository.
>
>      # From now on the submodule is on its own.
>      cd <submodule> && git config --list
>      # prints an "origin" remote and a lot more
>
> For a better explanation, I started a documentation series, see
> https://github.com/gitster/git/commit/e2b51b9df618ceeff7c4ec044e20f5ce9a87241e
>
> (It is not finished, but that is supposed to explain this exact pain
> point in the
> STATES section, feel free to point out missing things or what is hard
> to understand)
I am not sure I got much out of the STATES section regarding my problem.
>> what I would get is from someserver1 not someserver2 as there is no "origin"
>> support for submodules.  Is this correct?  If so can origin support be added
>> to submodules?
> Can you explain more in detail what you mean by origin support?
Yes so when we do a:
git push origin master

origin is of course the Remote (Remotes https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes)

So I best use terminology "Remotes" support. Git push supports remotes, but git submodules does not. The basic idea is this:

If Git allowed multiple submodule (https://git-scm.com/book/en/v2/Git-Tools-Submodules) Remotes to be specified say as an example:

git submodule add [remote] [url]

git submodule add origin https://github.com/chaconinc/DbConnector git submodule add indhouse https://indhouse .corp/chaconinc/DbConnector

Where:
[submodule "DbConnector"]
     path = DbConnector
     url = https://github.com/chaconinc/DbConnector
Could then change to:
[submodule "DbConnector"]
     path = DbConnector
     remote.origin.url = https://github.com/chaconinc/DbConnector
     remote.origin.url = https://indhouse .corp/chaconinc/DbConnector
Then it should be possible to get:
git submodules update --init --recursive
To support
git submodules update [remote] --init --recursive
And thus allow
git submodules update origin --init --recursive
git submodules update indhouse --init --recursive
Show 50 quoted lines
>
>> +-------------------------------
>>
>> So above was post from google group.  Maybe above is enough to explain the
>> problem that can result, but if not here is a discussion as to why this can
>> be confusing resulting to pushing or pulling from the incorrect server.
>>
>> Lets say projects starts at origin on https://server0.org. Project is then
>> brought in house to server https://indhouse.corp by developer A.
>>
>> Developer A then changes the submodule projects to point to indhouse and
>> changes submodules in super project to point to indhouse so everything is
>> great.
>>
>> Then Developer B clones from indhouse makes changes to submodule1 and
>> submodule1 and pushes them to indhouse.  Dev A tells Dev B hey thoes changes
>> are great why don't you push to public server0 so every one can get thoes
>> changes.  Dev B then git push origin branch_name on submodule1 and push
>> origin on submodule 2 and superproject.  And everything is great ... right?
>>
>> Yes by now those who know git know what dev B  forgot or more to the point
>> what git does not support in a "clean" way.  For those who don't enter the
>> life of dev C
>>
>> So dev C clones from server0 and performs a git submodule update --init
>> --recursive.  Now Dev C is on the www and can't see indhouse.corp and ...
>> kerpow... Dev B and Dev C just experienced one of the many SW mines on the
>> battlefield.
>>
>> I ask that git devs first see if I am correct with this assessment as I
>> could be wrong... maybe there is a way of doing this... and if not add a
>> feature to git to handle submodules and multiple origins cleanly.... and yes
>> beating dev B with rubber chicken might be a solution though I am looking
>> for a slightly better option.
> Yes this is a big point that we want to solve eventually.
>
> When devA brought it inhouse, what they meant to do was this:
> "This superproject is actually from server0, but we want to work on it, which
> may have submodules diverge from server0 eventually. So if a submodule changed
> you need to get it from the inhouse server, otherwise fall back to the server0".
>
> That way developerB can just make changes to some submodules and when
> devC clones
> they get the "correct" submodule.
>
> A weak attempt to do this is to use *relative* submodule urls. When
> using relative urls, and then mirroring the supeproject inhouse, then
> Git will look for the submodules as well inhouse, but there
> is no such "or if not found look at the original superprojects
> origin", which means, you have to mirror all submodules.
Yes I don't see how *relative* urls are a good solution.
Show 6 quoted lines
> And then about upstreaming changes. If you have a single repo (no
> submodules), you have to teach people to run "git remote add remote
> server0.org && git push upstream ...", but that you can do for each
> submodule. (This is tedious:/ but maybe ok; some submodules are free
> to sent things upstream whereas others are supersecret that you do not
> want to push upstream ever.)

So right yes there are ways and means this can fail and not be ultimately what the developer wants after all we all need to be aware of the repercussion of the commands typed at the terminal. My goal here is I notice a process that Git does not seem to handle well for a distributed revision control system and thought it could use some improvements. To your point on "supersecret" .... when pushing to origin git could always be allowed to notify the developer of multi remotes before pushing with a "freak-out" flag set by Dev A where git would then ask: git: are you sure [y/(n)] y git: are you sure your sure [y/(n)] Y git :you seem certain, but you might not be aware of the true consequences of your actions... are you sure you are sure that your are sure [Y/(N)] Y git: ..... Ok committing... it's your fault if this goes pear shaped sideways.

Show 5 quoted lines
> So yeah maybe we want to have more power in the superprojects push operation
>
>      (in the superproject) $ git push --recurse-submodules \
>         --only-these-submodules=subA,subB \
>         --submodule-to=upstream-as-configered-in-super-project
Sure ... Yes... plus "Remotes" support.
  git push --recurse-submodules \
        --only-these-submodules=subA,subB \
        --submodule-to=upstream-as-configered-in-super-project
Allow:
  git push [remote] --recurse-submodules \
        --only-these-submodules=subA,subB \
        --submodule-to=upstream-as-configered-in-super-project
  git push indhouse --recurse-submodules \
        --only-these-submodules=subA,subB \
        --submodule-to=upstream-as-configered-in-super-project
and
  git push origin --recurse-submodules \
        --only-these-submodules=subA,subB \
        --submodule-to=upstream-as-configered-in-super-project
> This is a lot of words but for explaining that is ok?
>
> Thanks,
> Stefan
Yep got it thanks.
Stefan Beller· Jan 17, 2017, 18:43 UTC · re: Brian J. Davis · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On Sun, Jan 15, 2017 at 1:02 PM, Brian J. Davis <bitminer@gmail.com> wrote:
Show 13 quoted lines
>>
>> Technically it is submodule.<name>.url instead of
>> submodule.<path>.url. The name is usually the path initially, and once
>> you move the submodule, only the path changes, the name is supposed to
>> be constant and stay the same.
>
> I am not certain what is meant by this.  All I know is I can use my
> "directory_to_checkout" above to place in tree relative from root the
> project any where in the tree not already tracked by git.  You state name
> instead of path, but it allows path correct? Either that or I have gone off
> reservation with my use of git for years now. Maybe this is a deviation from
> how it is documented/should work and how it actually works?  It works great
> how I use it.

Yes name can equal the path (and usually does). This is a minor detail that is only relevant for renaming submodules, so ... maybe let's not focus on it too much. :)

Show 27 quoted lines
>>>
>>>
>>> but if say I want to pull from some server 2 and do a
>>>
>>> git submodule update --init --recursive
>>
>> That is why the "git submodule init" exists at all.
>>
>>      git submodule init
>>      $EDIT .git/config # change submodule.<name>.url to server2
>>      git submodule update # that uses the adapted url and
>>      # creates the submodule repository.
>>
>>      # From now on the submodule is on its own.
>>      cd <submodule> && git config --list
>>      # prints an "origin" remote and a lot more
>>
>> For a better explanation, I started a documentation series, see
>>
>> https://github.com/gitster/git/commit/e2b51b9df618ceeff7c4ec044e20f5ce9a87241e
>>
>> (It is not finished, but that is supposed to explain this exact pain
>> point in the
>> STATES section, feel free to point out missing things or what is hard
>> to understand)
>
> I am not sure I got much out of the STATES section regarding my problem.
Your original problem as far as I understand is this:
  You have a project with submodules.
  The submodules are described in the .gitmodules file.
  But the URL is pointing to an undesired location.
  You want to rewrite the URLs before actually cloning the submodules.
And to solve this problem we need to perform multiple steps:
  # --no is the default, just for clarity here:
  git clone <project> --no-recurse-submodules
  # The submodules are now in the *uninitialized* state
  git submodule init
  # the submodules are in the initialized state
  git submodule update
  # submodules are populated, i.e. cloned from
  # the configured URLs and put into the working tree at
  # the appropriate path.

Between the init and the update step you can modify the URLs. These commands are just a repetition from the first email, but the git commands can be viewed as moving from one state to another for submodules; submodules itself can be seen as a state machine according to that proposed documentation. Maybe such a state machine makes it easier to understand for some people.

Show 39 quoted lines
>>> what I would get is from someserver1 not someserver2 as there is no
>>> "origin"
>>> support for submodules.  Is this correct?  If so can origin support be
>>> added
>>> to submodules?
>>
>> Can you explain more in detail what you mean by origin support?
>
> Yes so when we do a:
>
> git push origin master
>
> origin is of course the Remote (Remotes
> https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes)
>
> So I best use terminology "Remotes" support.  Git push supports remotes, but
> git submodules does not.  The basic idea is this:
>
> If Git allowed multiple submodule
> (https://git-scm.com/book/en/v2/Git-Tools-Submodules) Remotes to be
> specified say as an example:
>
> git submodule add [remote] [url]
>
> git submodule add origin https://github.com/chaconinc/DbConnector
> git submodule add indhouse https://indhouse .corp/chaconinc/DbConnector
>
> Where:
>
> [submodule "DbConnector"]
>     path = DbConnector
>     url = https://github.com/chaconinc/DbConnector
>
> Could then change to:
>
> [submodule "DbConnector"]
>     path = DbConnector
>     remote.origin.url = https://github.com/chaconinc/DbConnector
>     remote.origin.url = https://indhouse .corp/chaconinc/DbConnector

here I assume there is a typo and the second remote.origin.url should be remote.inhouse.url ?

Show 5 quoted lines
>
>
> Then it should be possible to get:
>
> git submodules update --init --recursive
which would setup the submodule with both
[remote "origin"]
  url = https://github.com/..
[remote "inhouse"]
  url = https://inhouse.corp/..

But where do we clone it from? (Or do we just do a "git init" on that submodule and fetch from both remotes? in which order?)

>
> To support
>
> git submodules update [remote] --init --recursive

This would just clone/fetch from the specified remote? If implementing this, we may run into a collision with the specified submodules, what if a submodule is at path "origin" ?

Does "git submodule update origin --init --recursive" then mean to update the single "origin" submodule or all submodules from their origin remote?

Show 6 quoted lines
>
> And thus allow
>
> git submodules update origin --init --recursive
>
> git submodules update indhouse --init --recursive

understood. I like the idea of being able to specify multiple remotes from the superproject..

Brian J. Davis· Jan 19, 2017, 23:11 UTC · re: Stefan Beller · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On 1/17/2017 12:43 PM, Stefan Beller wrote:
Show 68 quoted lines
> On Sun, Jan 15, 2017 at 1:02 PM, Brian J. Davis <bitminer@gmail.com> wrote:
>
>>> Technically it is submodule.<name>.url instead of
>>> submodule.<path>.url. The name is usually the path initially, and once
>>> you move the submodule, only the path changes, the name is supposed to
>>> be constant and stay the same.
>> I am not certain what is meant by this.  All I know is I can use my
>> "directory_to_checkout" above to place in tree relative from root the
>> project any where in the tree not already tracked by git.  You state name
>> instead of path, but it allows path correct? Either that or I have gone off
>> reservation with my use of git for years now. Maybe this is a deviation from
>> how it is documented/should work and how it actually works?  It works great
>> how I use it.
> Yes name can equal the path (and usually does). This is a minor detail
> that is only relevant for renaming submodules, so ... maybe let's not
> focus on it too much. :)
>
>>>>
>>>> but if say I want to pull from some server 2 and do a
>>>>
>>>> git submodule update --init --recursive
>>> That is why the "git submodule init" exists at all.
>>>
>>>       git submodule init
>>>       $EDIT .git/config # change submodule.<name>.url to server2
>>>       git submodule update # that uses the adapted url and
>>>       # creates the submodule repository.
>>>
>>>       # From now on the submodule is on its own.
>>>       cd <submodule> && git config --list
>>>       # prints an "origin" remote and a lot more
>>>
>>> For a better explanation, I started a documentation series, see
>>>
>>> https://github.com/gitster/git/commit/e2b51b9df618ceeff7c4ec044e20f5ce9a87241e
>>>
>>> (It is not finished, but that is supposed to explain this exact pain
>>> point in the
>>> STATES section, feel free to point out missing things or what is hard
>>> to understand)
>> I am not sure I got much out of the STATES section regarding my problem.
> Your original problem as far as I understand is this:
>
>    You have a project with submodules.
>    The submodules are described in the .gitmodules file.
>    But the URL is pointing to an undesired location.
>    You want to rewrite the URLs before actually cloning the submodules.
>
> And to solve this problem we need to perform multiple steps:
>
>    # --no is the default, just for clarity here:
>    git clone <project> --no-recurse-submodules
>    # The submodules are now in the *uninitialized* state
>
>    git submodule init
>    # the submodules are in the initialized state
>
>    git submodule update
>    # submodules are populated, i.e. cloned from
>    # the configured URLs and put into the working tree at
>    # the appropriate path.
>
> Between the init and the update step you can modify the URLs.
> These commands are just a repetition from the first email, but the
> git commands can be viewed as moving from one state to another
> for submodules; submodules itself can be seen as a state machine
> according to that proposed documentation. Maybe such a state machine
> makes it easier to understand for some people.
"Between the init and the update step you can modify the URLs."  Yes I can and have to... wish it was not this way.
Show 39 quoted lines
>>>> what I would get is from someserver1 not someserver2 as there is no
>>>> "origin"
>>>> support for submodules.  Is this correct?  If so can origin support be
>>>> added
>>>> to submodules?
>>> Can you explain more in detail what you mean by origin support?
>> Yes so when we do a:
>>
>> git push origin master
>>
>> origin is of course the Remote (Remotes
>> https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes)
>>
>> So I best use terminology "Remotes" support.  Git push supports remotes, but
>> git submodules does not.  The basic idea is this:
>>
>> If Git allowed multiple submodule
>> (https://git-scm.com/book/en/v2/Git-Tools-Submodules) Remotes to be
>> specified say as an example:
>>
>> git submodule add [remote] [url]
>>
>> git submodule add origin https://github.com/chaconinc/DbConnector
>> git submodule add indhouse https://indhouse .corp/chaconinc/DbConnector
>>
>> Where:
>>
>> [submodule "DbConnector"]
>>      path = DbConnector
>>      url = https://github.com/chaconinc/DbConnector
>>
>> Could then change to:
>>
>> [submodule "DbConnector"]
>>      path = DbConnector
>>      remote.origin.url = https://github.com/chaconinc/DbConnector
>>      remote.origin.url = https://indhouse .corp/chaconinc/DbConnector
> here I assume there is a typo and the second remote.origin.url should be
> remote.inhouse.url ?
yes second should have read remote.inhouse.url:
[submodule "DbConnector"]
     path = DbConnector
     remote.origin.url = https://github.com/chaconinc/DbConnector
     remote.inhouse.url = https://indhouse.corp/chaconinc/DbConnector
Show 14 quoted lines
>>
>> Then it should be possible to get:
>>
>> git submodules update --init --recursive
> which would setup the submodule with both
>
> [remote "origin"]
>    url = https://github.com/..
> [remote "inhouse"]
>    url = https://inhouse.corp/..
>
> But where do we clone it from?
> (Or do we just do a "git init" on that submodule and fetch
> from both remotes? in which order?)

origin by default and inhouse if specified. There is already a implied default (origin). The idea was not to do both but rather what is specified. Origin and inhouse are just names for remotes. If one wanted a "--all-remotes" could pull from everywhere in the Ether if feature was to be implemented.

Show 11 quoted lines
>> To support
>>
>> git submodules update [remote] --init --recursive
> This would just clone/fetch from the specified remote?
> If implementing this, we may run into a collision with the
> specified submodules, what if a submodule is at
> path "origin" ?
>
> Does "git submodule update origin --init --recursive"
> then mean to update the single "origin" submodule or
> all submodules from their origin remote?

Yes. That is what I would think. It does this already by default. It's not as though submodules were/are all that well thought out to begin with in git IMO.

Show 7 quoted lines
>> And thus allow
>>
>> git submodules update origin --init --recursive
>>
>> git submodules update indhouse --init --recursive
> understood. I like the idea of being able to specify
> multiple remotes from the superproject..

Yes so do I! It *could* be better than the current offering which is defaulted origin.

Stefan Beller· Jan 20, 2017, 01:22 UTC · re: Brian J. Davis · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

Show 10 quoted lines
>> Between the init and the update step you can modify the URLs.
>> These commands are just a repetition from the first email, but the
>> git commands can be viewed as moving from one state to another
>> for submodules; submodules itself can be seen as a state machine
>> according to that proposed documentation. Maybe such a state machine
>> makes it easier to understand for some people.
>
>
> "Between the init and the update step you can modify the URLs."  Yes I can
> and have to... wish it was not this way.

So how would yo u rather want to do it? look at the .gitmodules file beforehand and then run a "submodule update" ? Or a thing like

    git -c url.https://internal.insteadOf git://github.com/ \
        -c submodule.record-rewritten-urls submodule update

(no need for init there as theoretically there is not need for such an intermediate step)

Show 14 quoted lines
>> [remote "origin"]
>>    url = https://github.com/..
>> [remote "inhouse"]
>>    url = https://inhouse.corp/..
>>
>> But where do we clone it from?
>> (Or do we just do a "git init" on that submodule and fetch
>> from both remotes? in which order?)
>
> origin by default and inhouse if specified. There is already a implied
> default (origin). The idea was not to do both but rather what is specified.
> Origin and inhouse are just names for remotes. If one wanted a
> "--all-remotes" could pull from everywhere in the Ether if feature was to be
> implemented.

How is origin implied to be the default? Should there be an order (e.g. if you cannot find it at inhouse get it from github, if they are down, get it from kernel.org)

Brian J. Davis· Jan 21, 2017, 15:53 UTC · re: Stefan Beller · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On 1/19/2017 7:22 PM, Stefan Beller wrote:
Show 19 quoted lines
>>> Between the init and the update step you can modify the URLs.
>>> These commands are just a repetition from the first email, but the
>>> git commands can be viewed as moving from one state to another
>>> for submodules; submodules itself can be seen as a state machine
>>> according to that proposed documentation. Maybe such a state machine
>>> makes it easier to understand for some people.
>>
>> "Between the init and the update step you can modify the URLs."  Yes I can
>> and have to... wish it was not this way.
> So how would yo u rather want to do it?
> look at the .gitmodules file beforehand and then run a "submodule update" ?
> Or a thing like
>
>      git -c url.https://internal.insteadOf git://github.com/ \
>          -c submodule.record-rewritten-urls submodule update
>
> (no need for init there as theoretically there is not
> need for such an intermediate step)
>
"Yes please and thank you" ... both.
My thought was to simply allow addition to .gitmodules.  If I understand 
correctly you are proposing, to override these at the command line and 
possibly rewrite them on submodule update, but maybe not save or add to 
.gitmodules. I would then propose both.
1) allow user to add to .gitmodules for those who do not care that 
"outsiders" know the internal dev server
and
2) allow to rewrite while not saving to .gitmodules on fresh clone and 
submodule update for thoes that do not want ousiders to known internal 
dev server.
and possibly:
3) allow at command line to add remote to .gitmodules on submodule 
commands (note add optoin in -c <name> = <value> pair)
.gitmodules before:
[submodule "subprojects/wrangler"]
         path = subprojects/wrangler
         url = git://github.com/
Then your adapted command:
git -c url.https://internal.insteadOf git://github.com/ \
         -c submodule.record-rewritten-urls=add,internal --add submodule update
would produce
[submodule "subprojects/projname"]
         path = subprojects/projname
         remote.origin.url = git://github.com/
         remote.internal.url =https://internal.insteadOf
Or similar support.
Show 17 quoted lines
>>> [remote "origin"]
>>>     url = https://github.com/..
>>> [remote "inhouse"]
>>>     url = https://inhouse.corp/..
>>>
>>> But where do we clone it from?
>>> (Or do we just do a "git init" on that submodule and fetch
>>> from both remotes? in which order?)
>> origin by default and inhouse if specified. There is already a implied
>> default (origin). The idea was not to do both but rather what is specified.
>> Origin and inhouse are just names for remotes. If one wanted a
>> "--all-remotes" could pull from everywhere in the Ether if feature was to be
>> implemented.
> How is origin implied to be the default?
> Should there be an order (e.g. if you cannot find it at inhouse get it
> from github,
> if they are down, get it from kernel.org)

As it is in the Highlander series... "there can be only one" (remote). So that is what I mean by origin. The only remote allowed is the "origin" unless changed by the user... but there can still only be one *currently*. Though I see your point as it is not labeled "origin". It is not labeled at all. Apologies for confusion there.

Stefan Beller· Jan 24, 2017, 18:49 UTC · re: Brian J. Davis · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On Sat, Jan 21, 2017 at 7:53 AM, Brian J. Davis <bitminer@gmail.com> wrote:
Show 62 quoted lines
>
> On 1/19/2017 7:22 PM, Stefan Beller wrote:
>>>>
>>>> Between the init and the update step you can modify the URLs.
>>>> These commands are just a repetition from the first email, but the
>>>> git commands can be viewed as moving from one state to another
>>>> for submodules; submodules itself can be seen as a state machine
>>>> according to that proposed documentation. Maybe such a state machine
>>>> makes it easier to understand for some people.
>>>
>>>
>>> "Between the init and the update step you can modify the URLs."  Yes I
>>> can
>>> and have to... wish it was not this way.
>>
>> So how would yo u rather want to do it?
>> look at the .gitmodules file beforehand and then run a "submodule update"
>> ?
>> Or a thing like
>>
>>      git -c url.https://internal.insteadOf git://github.com/ \
>>          -c submodule.record-rewritten-urls submodule update
>>
>> (no need for init there as theoretically there is not
>> need for such an intermediate step)
>>
> "Yes please and thank you" ... both.
>
> My thought was to simply allow addition to .gitmodules.  If I understand
> correctly you are proposing, to override these at the command line and
> possibly rewrite them on submodule update, but maybe not save or add to
> .gitmodules. I would then propose both.
> 1) allow user to add to .gitmodules for those who do not care that
> "outsiders" know the internal dev server
> and
> 2) allow to rewrite while not saving to .gitmodules on fresh clone and
> submodule update for thoes that do not want ousiders to known internal dev
> server.
> and possibly:
> 3) allow at command line to add remote to .gitmodules on submodule commands
> (note add optoin in -c <name> = <value> pair)
>
> .gitmodules before:
>
> [submodule "subprojects/wrangler"]
>         path = subprojects/wrangler
>         url = git://github.com/
>
> Then your adapted command:
>
> git -c url.https://internal.insteadOf git://github.com/ \
>         -c submodule.record-rewritten-urls=add,internal --add submodule
> update
>
> would produce
>
> [submodule "subprojects/projname"]
>         path = subprojects/projname
>         remote.origin.url = git://github.com/
>         remote.internal.url =https://internal.insteadOf
>
> Or similar support.

I think this was avoided until now as it would rewrite/add history. So what if you want ot "just mirror" a large project with a lot of submodules? You would want to do that without touching the history, hence we'd need to do such a configuration in a separate place. IIRC there was a proposal to have a ref e.g. "refs/submodule/config", that can overwrite/extend the .gitmodules file with your own configuration. It is a ref, such that mirroring would work, but not part of the main history, such that yoiu can still change it.

I think to get it right we need to enable a workflow that allows easy "multi-step" mirroring, e.g. A (source of truth) can be mirrored to B, who can overlay the .gitmodules to point to server-B, which then can be mirrored by C, who can have its own serverC.

When C forgot to configure all the submodules, it should fall back to serverB as that was closest, and if that is unconfigured it should fallback to A IMO.

Show 28 quoted lines
>
>>>> [remote "origin"]
>>>>     url = https://github.com/..
>>>> [remote "inhouse"]
>>>>     url = https://inhouse.corp/..
>>>>
>>>> But where do we clone it from?
>>>> (Or do we just do a "git init" on that submodule and fetch
>>>> from both remotes? in which order?)
>>>
>>> origin by default and inhouse if specified. There is already a implied
>>> default (origin). The idea was not to do both but rather what is
>>> specified.
>>> Origin and inhouse are just names for remotes. If one wanted a
>>> "--all-remotes" could pull from everywhere in the Ether if feature was to
>>> be
>>> implemented.
>>
>> How is origin implied to be the default?
>> Should there be an order (e.g. if you cannot find it at inhouse get it
>> from github,
>> if they are down, get it from kernel.org)
>
> As it is in the Highlander series... "there can be only one" (remote).   So
> that is what I mean by origin.  The only remote allowed is the "origin"
> unless changed by the user... but there can still only be one *currently*.
> Though I see your point as it is not labeled "origin".  It is not labeled at
> all.  Apologies for confusion there.

"origin" is just a common name for a remote, like "master" is a common name for branches. There is nothing inherently special about these except for their automatic setup after cloning/initializing a repo.

So you can delete the master branch (which I did in a project that I am not the authoritative maintainer of; I only have feature branches), and the repository just works fine.

Brian J. Davis· Jan 25, 2017, 07:14 UTC · re: Stefan Beller · lore

Re: submodule network operations [WAS: Re: [RFC/PATCH 0/4] working tree operations: support superprefix]

On 1/24/2017 12:49 PM, Stefan Beller wrote:
Show 67 quoted lines
> On Sat, Jan 21, 2017 at 7:53 AM, Brian J. Davis <bitminer@gmail.com> wrote:
>> On 1/19/2017 7:22 PM, Stefan Beller wrote:
>>>>> Between the init and the update step you can modify the URLs.
>>>>> These commands are just a repetition from the first email, but the
>>>>> git commands can be viewed as moving from one state to another
>>>>> for submodules; submodules itself can be seen as a state machine
>>>>> according to that proposed documentation. Maybe such a state machine
>>>>> makes it easier to understand for some people.
>>>>
>>>> "Between the init and the update step you can modify the URLs."  Yes I
>>>> can
>>>> and have to... wish it was not this way.
>>> So how would yo u rather want to do it?
>>> look at the .gitmodules file beforehand and then run a "submodule update"
>>> ?
>>> Or a thing like
>>>
>>>       git -c url.https://internal.insteadOf git://github.com/ \
>>>           -c submodule.record-rewritten-urls submodule update
>>>
>>> (no need for init there as theoretically there is not
>>> need for such an intermediate step)
>>>
>> "Yes please and thank you" ... both.
>>
>> My thought was to simply allow addition to .gitmodules.  If I understand
>> correctly you are proposing, to override these at the command line and
>> possibly rewrite them on submodule update, but maybe not save or add to
>> .gitmodules. I would then propose both.
>> 1) allow user to add to .gitmodules for those who do not care that
>> "outsiders" know the internal dev server
>> and
>> 2) allow to rewrite while not saving to .gitmodules on fresh clone and
>> submodule update for thoes that do not want ousiders to known internal dev
>> server.
>> and possibly:
>> 3) allow at command line to add remote to .gitmodules on submodule commands
>> (note add optoin in -c <name> = <value> pair)
>>
>> .gitmodules before:
>>
>> [submodule "subprojects/wrangler"]
>>          path = subprojects/wrangler
>>          url = git://github.com/
>>
>> Then your adapted command:
>>
>> git -c url.https://internal.insteadOf git://github.com/ \
>>          -c submodule.record-rewritten-urls=add,internal --add submodule
>> update
>>
>> would produce
>>
>> [submodule "subprojects/projname"]
>>          path = subprojects/projname
>>          remote.origin.url = git://github.com/
>>          remote.internal.url =https://internal.insteadOf
>>
>> Or similar support.
> I think this was avoided until now as it would rewrite/add history.
> So what if you want ot "just mirror" a large project with a lot
> of submodules? You would want to do that without touching
> the history, hence we'd need to do such a configuration in a separate
> place. IIRC there was a proposal to have a ref e.g.
> "refs/submodule/config", that can overwrite/extend the .gitmodules
> file with your own configuration. It is a ref, such that mirroring would
> work, but not part of the main history, such that yoiu can still change it.

How would this handle the hashes for the submodules tracked in the super project. This gets to my earlier statement that git submodules is not really that well thought out. When/if /refs/submodule/config overwrites/extends .gitmoduels what does git checkout for a hash code (version) for the subproject? Maybe there are some simple ways of doing this, but it really seems to me that git submodules needs an overhaul to support multiple remotes. Would the refs/submodule/config also include the versions hashes for the submodule for both remotes? When switching between remotes would the git submodule update pull the correct hash version for the subproject and pull the correct version of the subproject?

Show 38 quoted lines
> I think to get it right we need to enable a workflow that allows easy
> "multi-step" mirroring, e.g. A (source of truth) can be mirrored to B,
> who can overlay the .gitmodules to point to server-B, which then can
> be mirrored by C, who can have its own serverC.
>
> When C forgot to configure all the submodules, it should fall back to
> serverB as that was closest, and if that is unconfigured it should
> fallback to A IMO.
>
>
>
>>>>> [remote "origin"]
>>>>>      url = https://github.com/..
>>>>> [remote "inhouse"]
>>>>>      url = https://inhouse.corp/..
>>>>>
>>>>> But where do we clone it from?
>>>>> (Or do we just do a "git init" on that submodule and fetch
>>>>> from both remotes? in which order?)
>>>> origin by default and inhouse if specified. There is already a implied
>>>> default (origin). The idea was not to do both but rather what is
>>>> specified.
>>>> Origin and inhouse are just names for remotes. If one wanted a
>>>> "--all-remotes" could pull from everywhere in the Ether if feature was to
>>>> be
>>>> implemented.
>>> How is origin implied to be the default?
>>> Should there be an order (e.g. if you cannot find it at inhouse get it
>>> from github,
>>> if they are down, get it from kernel.org)
>> As it is in the Highlander series... "there can be only one" (remote).   So
>> that is what I mean by origin.  The only remote allowed is the "origin"
>> unless changed by the user... but there can still only be one *currently*.
>> Though I see your point as it is not labeled "origin".  It is not labeled at
>> all.  Apologies for confusion there.
> "origin" is just a common name for a remote, like "master" is a common name
> for branches. There is nothing inherently special about these except for
> their automatic setup after cloning/initializing a repo.

Origin is the remote from where all was derived and yes it can certainly be renamed or deleted (provided another remote name exists) in git. Sadly "master" is a term used in git which always implies another term. I thought term "master" was long since killed in the computer world with the USB 1.1 to 2.0 debate, ... but here it still lives in git. What is wrong with the term trunk? Trees don't have masters... they have trunks... but i digress on the term "master". I will try and get my git terms right even if IMO they are at times the wrong terms.

> So you can delete the master branch (which I did in a project
> that I am not the authoritative maintainer of; I only have feature
> branches), and
> the repository just works fine.
I too have deleted the "master" branches in previous projects.

← back to recent threads