Re: [PATCH] Let .git/config specify the url for submodules

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Let .git/config specify the url for submodules

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:13

Linus Torvalds [off-list ref] writes:
On Fri, 1 Jun 2007, Lars Hjemli wrote:
...
Ack. I think the natural thing for a lot of cases is the trivial "module 
name == path" case, so having to have

	[path "kernel"]
		module = kernel

for that case just sounds unnecessary.

That said, I wonder if it wouldn't be more natural to do things the other 
way around, because quite often a "module" (under CVS conventions) is a 
*set* of directories, so with that in mind, it might be better to have the 
mapping be something like this:

	[module "infrastructure"]
		submodule = lib
		submodule = build

	[submodule "lib"]
		url = git://xyzzy/lib-1.2.3

	[submodule "build"]
		url = git://xyzzy/build-0.61

and make the rule be:
 - submodules are named by their paths (ie "path == submodule")
 - a module is a set of such submodules/paths
 - if no "module" is defined, the default is to just use the 
   path/submodule name
I take that if you do want to name a submodule differently from
its (currently in-tree) path, you would do something like...

	[submodule "xyzzylib"]
        	path = lib
                url = git://xyzzy/lib-1.2.3
IOW, in the above case, we have *three* modules:

 - module "infrastructure", that is the union of submodules/paths "lib" 
   and "build"
 - module "lib" (== submodule/path "lib")
 - module "build" (== submodule/path "build")

and when you do a 

	git submodule checkout infrastructure

it would be basically equivalent to

	git submodule checkout lib
	git submodule checkout build
Sounds very sensible.

Re: [PATCH] Let .git/config specify the url for submodules

From: Lars Hjemli <hidden>
Date: 2016-06-15 22:43:13

On 6/1/07, Junio C Hamano [off-list ref] wrote:
Linus Torvalds [off-list ref] writes:
quoted
On Fri, 1 Jun 2007, Lars Hjemli wrote:
...
Ack. I think the natural thing for a lot of cases is the trivial "module
name == path" case, so having to have

      [path "kernel"]
              module = kernel

for that case just sounds unnecessary.

That said, I wonder if it wouldn't be more natural to do things the other
way around, because quite often a "module" (under CVS conventions) is a
*set* of directories, so with that in mind, it might be better to have the
mapping be something like this:

      [module "infrastructure"]
              submodule = lib
              submodule = build

      [submodule "lib"]
              url = git://xyzzy/lib-1.2.3

      [submodule "build"]
              url = git://xyzzy/build-0.61

and make the rule be:
 - submodules are named by their paths (ie "path == submodule")
 - a module is a set of such submodules/paths
 - if no "module" is defined, the default is to just use the
   path/submodule name
I take that if you do want to name a submodule differently from
its (currently in-tree) path, you would do something like...

        [submodule "xyzzylib"]
                path = lib
                url = git://xyzzy/lib-1.2.3
The reason I wanted to use

[path "lib"]
  submodule=xyzzylib
  url=git://xyzzy/lib-1.2.3

is that the git-submodule command always starts out with the submodule
path, trying to map that to an url or a submodule name. My proposal
allows

  $ name=$(GIT_CONFIG=.gitmodules git-config path."$path".submodule)
  $ url=$(GIT_CONFIG=.gitmodules git-config path."$path".url)


Then Sven suggested to create a submodule section for the url, which would allow

  $ name=$(GIT_CONFIG=.gitmodules git-config path."$path".submodule)
  $ url=$(GIT_CONFIG=.gitmodules git-config submodule."$name".url)


But I don't see an easy way to do the mapping from path to url/submodule with:

[submodule "xyzzylib"]
  path=lib
  url=git://xyzzy/lib-1.2.3

Suggestions?

--
larsh

Re: [PATCH] Let .git/config specify the url for submodules

From: Sven Verdoolaege <hidden>
Date: 2016-06-15 22:43:13

On Sat, Jun 02, 2007 at 09:13:55AM +0200, Lars Hjemli wrote:
Then Sven suggested to create a submodule section for the url, which would 
allow

 $ name=$(GIT_CONFIG=.gitmodules git-config path."$path".submodule)
 $ url=$(GIT_CONFIG=.gitmodules git-config submodule."$name".url)


But I don't see an easy way to do the mapping from path to url/submodule 
with:

[submodule "xyzzylib"]
 path=lib
 url=git://xyzzy/lib-1.2.3

Suggestions?
I'm not a shell programmer, but it could look something like this

    $ name=$(git config --get-regexp 'submodule\..*\.path' | while read module modulepath; do if test "$modulepath" = "$path"; then echo $module | sed -e 's/^submodule.//' -e 's/.path//'; fi; done)

skimo

Re: [PATCH] Let .git/config specify the url for submodules

From: Lars Hjemli <hidden>
Date: 2016-06-15 22:43:13

On 6/2/07, Sven Verdoolaege [off-list ref] wrote:
On Sat, Jun 02, 2007 at 09:13:55AM +0200, Lars Hjemli wrote:
quoted
Then Sven suggested to create a submodule section for the url, which would
allow

 $ name=$(GIT_CONFIG=.gitmodules git-config path."$path".submodule)
 $ url=$(GIT_CONFIG=.gitmodules git-config submodule."$name".url)


But I don't see an easy way to do the mapping from path to url/submodule
with:

[submodule "xyzzylib"]
 path=lib
 url=git://xyzzy/lib-1.2.3

Suggestions?
I'm not a shell programmer,
Me neither ;-)
but it could look something like this

    $ name=$(git config --get-regexp 'submodule\..*\.path' | while read module modulepath; do if test "$modulepath" = "$path"; then echo $module | sed -e 's/^submodule.//' -e 's/.path//'; fi; done)
Ahh, --get-regexp, thanks.

Then this actually works:

name=$(GIT_CONFIG=.gitmodules git-config --get-regexp
'submodule\..*\.path' 'lib' | sed -e 's/^submodule\.\(.*\)\.path
lib$/\1/')


But why would we want to design .gitmodules in a way that makes it
hard to do the mapping from path to url?

-- 
larsh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help