serving git with both "git:" and "http:" and submodules
I have a public tree that I maintain for users. The tree is consisted of a main-tree and a submodule tree which is also served from the same server.
The main tree:git://my-domain.org/my-tree/.git
The sub-tree:git://my-domain.org/my-tree/sub/.git
in my .gitmodule I have the usual
[submodule "sub"]
url = git://my-domain.org/my-tree/sub/.git
So smart people using git will just do:
1. $ git clone git://my-domain.org/my-tree/.git
2. $ git submodule init
3. $ git submodule update
And all is well... But smart ass corporate people would not use "git:" protocol because of fire-walls and for them I have a dumb "http:" export as:
1. $ git clone http://my-domain.org/trees/my-tree/.git
With them, step 3 above will not work. My current instructions for them is that after the step 2 "git submodule init" they should manually edit my-tree/.git/config and change to:
[submodule "sub"]
- url = git://my-domain.org/my-tree/sub/.git
+ url = http://my-domain.org/trees/my-tree/sub/.git
And then do step 3 to clone the sub-module.
So my question is: Can I automate this so people with "http:" clones are not forced to manually edit their config files? (Some users are just not up to it)
Thanks, (Sorry if that has been raised before. Couldn't find any.) Boaz
Quoted 9 lines · Boaz Harrosh
So smart people using git will just do:
1. $ git clonegit://my-domain.org/my-tree/.git
2. $ git submodule init
3. $ git submodule updateAnd all is well... But smart ass corporate people would not use "git:" protocol because of fire-walls and for them I have a dumb "http:" export as:
1. $ git clone http://my-domain.org/trees/my-tree/.git
[...]
Quoted 3 lines
So my question is: Can I automate this so people with "http:" clones are not forced to manually edit their config files? (Some users are just not up to it)
Sure. For example, you can ship an update-submodules.sh script to take care of checking “git config remote.origin.url” and updating the ‘[submodule "sub"] url’ configuration to match.
Of course, even this would not make
'git clone --recursive http://my-domain.org/trees/my-tree/.git'
work. If you can get git-http-backend working, I’d suggest using that so you only have to deal with one url.
Hope that helps,
Jonathan
Quoted 16 lines · Jonathan Nieder
Quoted 9 lines · Boaz Harrosh
So smart people using git will just do:
1. $ git clonegit://my-domain.org/my-tree/.git
2. $ git submodule init
3. $ git submodule updateAnd all is well... But smart ass corporate people would not use "git:" protocol because of fire-walls and for them I have a dumb "http:" export as:
1. $ git clone http://my-domain.org/trees/my-tree/.git[...]
Quoted 3 lines
So my question is: Can I automate this so people with "http:" clones are not forced to manually edit their config files? (Some users are just not up to it)
Quoted 6 lines
Sure. For example, you can ship an
update-submodules.shscript to take care of checking “git config remote.origin.url” and updating the ‘[submodule "sub"] url’ configuration to match.Of course, even this would not make
'git clone --recursive http://my-domain.org/trees/my-tree/.git'
Right
Quoted 3 lines
work. If you can get git-http-backend working, I’d suggest using that so you only have to deal with one url.
Ok I'll dive into "git-http-backend" (any pointers). But I thought this one will still serve me an "http:" url. Are you suggesting to just drop the "git:" protocol? (Since "git-http-backend" is just as good, through http?)
Quoted 2 lines
Hope that helps,
Jonathan
But a script for users might be a very good idea. I might even add it to the main Makefile. And make it totally transparent.
$ git-clone; make;
Thanks that actually helped
Boaz
Quoted 1 line · Boaz Harrosh
Ok I'll dive into "git-http-backend" (any pointers).
The reference manual[1] is all I know of. Googling reveals a nice overview[2] by Scott Chacon.
Quoted 3 lines
Are you suggesting to
just drop the "git:" protocol? (Since "git-http-backend" is just as good, through http?)
Exactly[3].
Quoted 1 line
Thanks that actually helped
Glad to be useful. :)
Good luck,
Jonathan
[1] http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html
[2] http://progit.org/2010/03/04/smart-http.html
[3] Well, the protocol overhead is a little higher, but that is nothing compared to the difference between git: and traditional static http:.
Quoted 3 lines · Jonathan Nieder
Quoted 2 lines · Boaz Harrosh
So my question is: Can I automate this so people with "http:" clones are not forced to manually edit their config files?
Almost.
Quoted 3 lines
Of course, even this would not make
'git clone --recursive http://my-domain.org/trees/my-tree/.git'
work.
Firewall-ed users can just run
$ git config --global url.http://my-domain.org/.insteadOf git://my-domain.org/
*once* per user per machine, or even
$ git config --global url.http.insteadOf git
if they want to be really aggressive. After that they can just pretend to use the git protocol and all URLs will be mapped under the hood:
git clone --recursive git://my-domain.org/...
-Brad
Boaz Harrosh:
Quoted 4 lines
[submodule "sub"]
url = git://my-domain.org/my-tree/sub/.gitSo my question is: Can I automate this so people with "http:" clones are not forced to manually edit their config files?
You should be able to use a relative URL in .gitmodules, something like this should work:
[submodule "sub"]
url = ../sub/.git
Signature · 1 line
\\// Peter - http://www.softwolves.pp.se/
PATCH 1/1 gitmodules.5: url can be a relative path
There is already excellent documentation for this facility in git-submodule.1, but it is not so discoverable.
Relative paths in .gitmodules can be useful for serving the same repository over multiple protocols, for example. Thanks to Peter for pointing this out.
--- Documentation/gitmodules.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Documentation/gitmodules.txt +3 -0
@@ -29,6 +29,9 @@ submodule.<name>.path:: submodule.<name>.url:: Defines an url from where the submodule repository can be cloned. + This may be either an absolute URL ready to be passed to + linkgit:git-clone[1] or (if it begins with ./ or ../) a location + relative to the superproject's origin repository. submodule.<name>.update:: Defines what to do when the submodule is updated by the superproject.
Signature · 1 line
1.7.2.rc2
PATCH 1/1 Documentation: add submodule.* to the big configuration variable list
The url, path, and update items in [submodule "foo"] stanzas are nicely explained in the .gitmodules and ‘git submodule’ documentation. Point there from the config documentation.
---
It’s late, so I don’t trust this to be coherent English necessarily. Thoughts and improvements welcome.
Documentation/config.txt | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
Documentation/config.txt +9 -0
@@ -1685,6 +1685,15 @@ status.submodulesummary:: summary of commits for modified submodules will be shown (see --summary-limit option of linkgit:git-submodule[1]). +submodule.<name>.path:: +submodule.<name>.url:: +submodule.<name>.update:: + The path within this project, URL, and updating strategy + for a submodule. These variables are initially populated + by 'git submodule init'; edit them to override the + URL and other values found in the `.gitmodules` file. See + linkgit:git-submodule[1] and linkgit:gitmodules[5] for details. + tar.umask:: This variable can be used to restrict the permission bits of tar archive entries. The default is 0002, which turns off the
Signature · 1 line
1.7.2.rc2
Re: [PATCH] Documentation: add submodule.* to the big configuration variable list
Quoted 5 lines · Jonathan Nieder
The url, path, and update items in [submodule "foo"] stanzas are nicely explained in the .gitmodules and ‘git submodule’ documentation. Point there from the config documentation.
Signed-off-by Jonathan Nieder <[email protected]>
Quoted 12 lines
---
It’s late, so I don’t trust this to be coherent English necessarily. Thoughts and improvements welcome.Documentation/config.txt | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)Documentation/config.txt +0
-0
Documentation/config.txt status.submodulesummary:: · line 1691
Quoted 7 lines
Documentation/config.txt +4
-0@@ -1685,6 +1685,15 @@ status.submodulesummary:: summary of commits for modified submodules will be shown (see --summary-limit option of linkgit:git-submodule[1]). +submodule.<name>.path:: +submodule.<name>.url:: +submodule.<name>.update:: + The path within this project, URL, and updating strategy
May be more legible with:
The path within this project, the URL, and the updating strategy...
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [PATCH] Documentation: add submodule.* to the big configuration variable list
Quoted 3 lines · Johan Herland
May be more legible with:
The path within this project, the URL, and the updating strategy...
Thanks, Johan. I’ve pushed both patches out to
git://repo.or.cz/git/jrn.git submodule-doc
including that change.
Jonathan Nieder (2):
gitmodules.5: url can be a relative path
Documentation: add submodule.* to the big configuration variable list
Documentation/config.txt | 9 +++++++++ Documentation/gitmodules.txt | 3 +++ 2 files changed, 12 insertions(+), 0 deletions(-)
Re: [PATCH] gitmodules.5: url can be a relative path
In reply to Jonathan NiederQuoted 9 lines · Jonathan Nieder
There is already excellent documentation for this facility in git-submodule.1, but it is not so discoverable.
Relative paths in .gitmodules can be useful for serving the same repository over multiple protocols, for example. Thanks to Peter for pointing this out.
Cc Peter Krefting <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [PATCH] gitmodules.5: url can be a relative path
In reply to Jonathan NiederQuoted 7 lines · Jonathan Nieder
There is already excellent documentation for this facility in git-submodule.1, but it is not so discoverable.
Relative paths in .gitmodules can be useful for serving the same repository over multiple protocols, for example. Thanks to Peter for pointing this out.
You guys rock. It's exactly what the doctor ordered
Thanks
Boaz