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

Re: [RFC PATCH] Move git-dir for submodules

From
Phil Hord <hordp@cisco.com>
Date
Jul 21, 2011, 21:50 UTC
Message-ID
<4E289F42.4040708@cisco.com>
In-Reply-To
<4E289CDA.20209@cisco.com>
On 07/21/2011 05:40 PM, Phil Hord wrote:
Show 27 quoted lines
> On 07/21/2011 04:28 PM, Junio C Hamano wrote:
>> Fredrik Gustafsson<iveqy@iveqy.com>  writes:
>>
>>> diff --git a/git-submodule.sh b/git-submodule.sh
>>> index 87c9452..3ad3012 100755
>>> --- a/git-submodule.sh
>>> +++ b/git-submodule.sh
>>> @@ -122,14 +122,56 @@ module_clone()
>>>       path=$1
>>>       url=$2
>>>       reference="$3"
>>> +    gitdir=
>>> +    gitdir_base=
>>> +    base_path=`echo $path | sed -e 's|[^/]*$||'`
>> We prefer $() over `` these days, no?  Without dq around $path, you 
>> would
>> not be able to preserve $IFS inside $PATH. You are stripping a run of 
>> non
>> slash at the trailing end --- is 'dirname "$path"' insufficient?
>>
>> I think you are using the path the submodule happens to be at in the
>> current checkout to decide where in the .git/modules in the superproject
>> to keep the submodule metadata directory. Shouldn't you be using
>> module_name to convert the $path to the name of the submodule (this is
>> important, as the same submodule that used to be at path P1 can be moved
>> to a different path P2 in the history).
>
[ Sending this again to unwrap my table. Sorry for the noise. ]

Now that you mention it, what happens if the submodule name changes in the history? What happens if the submodule URL (and possibly the entire submodule contents) changes in the history?

Is there any unique thing simpler than "<submodule-name>+<url>" that can be used to uniquely identify "that" submodule repo?

Say I have linux as a submodule in my project. But over time (or on different branches) I have different ideas about what should go there. what it should be called and where it should go:

Commit      .gitmodules
  E           linux.path=linux ; linux.url=/blackfin/uclinux-kernel
  D           linux.path=linux ; linux.url=/github/mirrors/linux-2.6.git
  C           linux.path=linux ; linux.url=/torvalds/linux-2.6.git
  B           linux.path=linus ; linux.url=/torvalds/linux-2.6.git
  A           linus.path=linus ; linus.url=/torvalds/linux-2.6.git

How many repos are in .git/modules/? I can imagine anything from 1-5 in the implementation. Logically there should be only 2, ideally (but not practically) named something like this:

  .git/modules/linux@blackfin
  .git/modules/linux@torvalds
and where the last one also includes "github/mirrors" as a remote.

But a more practical implementation would end up with three as it wouldn't presume to combine the last two:

  .git/modules/linux@blackfin
  .git/modules/linux@torvalds
  .git/modules/linux@github

But maybe a nearly practical implementation could actually wind up with one repo and three remotes:

  .git/modules/linux; remotes=blackfin, torvalds, github

But this is likely to confuse the poor user who did not expect all these remotes. A realistic practical implementation probably would wind up more like this:

  .git/modules/linux; remotes=blackfin, torvalds, github
  .git/modules/linus; remotes=torvalds

In reality I suppose switching repositories like this is simply not supported by the code or the patch. But it's something to think about when choosing a name for the .git/modules path.

Phil
> -- 
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Phil HordNext: Junio C Hamano
Message 4 of 8 in “Move git-dir for submodules”
  1. Move git-dir for submodulesFredrik Gustafsson, Jul 21, 2011
  2. Junio C HamanoJul 21, 2011
  3. Phil HordJul 21, 2011
  4. Phil HordJul 21, 2011
  5. Junio C HamanoJul 21, 2011
  6. Junio C HamanoJul 21, 2011
  7. Fredrik GustafssonJul 22, 2011
  8. Junio C HamanoJul 22, 2011

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.