git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Re: Relative submodule URLs, and forks that haven't forked the submodule

From
W. Trevor King <wking@tremily.us>
Date
Jun 12, 2014, 18:05 UTC
Message-ID
<20140612180543.GA28801@odin.tremily.us>
In-Reply-To
<DF027A78-FAC4-4120-9259-1A3D84635BDB@lltech.fr>
On Thu, Jun 12, 2014 at 06:05:10PM +0200, Charles Brossollet wrote:
Show 6 quoted lines
> The two problems I'm pointing are:
> 
> 1. After checkout of a branch that tracks /user/main repo, call git
>    init submodule motors. Git registers it in .git/config with URL
>    /user/sub, while it should be /central/sub according to
>    documentation because origin's URL is at /central.

The logic for this is in resolve_relative_url, defined in git-submodule.sh. The remote it uses is calculated using get_default_remote, defined in git-parse-remote.sh:

  get_default_remote () {
    curr_branch=$(git symbolic-ref -q HEAD)
    curr_branch="${curr_branch#refs/heads/}"
    origin=$(git config --get "branch.$curr_branch.remote")
    echo ${origin:-origin}
  }
Show 5 quoted lines
> 2. For an obscure reason, changing the url in .git/config to
> /central/sub and call git submodule update still make git want to
> clone from /user/sub, and fails. There seems to be no way to tell
> git the right URL for this submodule, while it should be possible
> according to the submodule documentation.
This is very surprising to me.  With Git v1.9.1:
* Clone just the superproject, without it's sibling submodule projects:
  $ git clone git://github.com/wking/pygrader.git pg-1
* Clone the isolated superproject, so we'll have broken relative URLs:
  $ git clone pg-1 pg-2
* Initialize a submodule:
  $ git submodule init dep/src/pyassuan
* Fix the broken, expanded-from-relative URL to point back to the
  original:
  $ git config submodule.dep/src/pyassuan.url git://github.com/wking/pyassuan.git
* Initial, cloning update:
  $ git submodule update
That all works as expected for me.

Cheers, Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
Previous: Charles Brossollet
Message 4 of 4 in “Relative submodule URLs, and forks that haven't forked the submodule”
  1. Charles BrossolletJun 11, 2014
  2. Fredrik GustafssonJun 12, 2014
  3. Charles BrossolletJun 12, 2014
  4. W. Trevor KingJun 12, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.