supporting roaming via git URL rewriting
Adam Spiers
vcs-home at adamspiers.org
Fri Dec 23 16:01:01 CET 2011
On Fri, Dec 23, 2011 at 1:17 PM, Dieter Plaetinck <dieter at plaetinck.be> wrote:
> On Fri, 23 Dec 2011 07:41:29 +1000
> Bruce Schultz <bruce.schultz at gmail.com> wrote:
>
>> I solved that situation by adding the external name (ie
>> public.adamspiers.org) to the DNS on my ADSL router.
>>
>> So if I'm on my LAN at home, public.adamspiers.org -> 10.0.0.12
>>
>> But if I'm away from the house, its port forwarded through the router
>> to my workstation.
>
> +1. this problem is much broader in scope than some git repositories
> or even services which only rely on ssh. (as somebody suggested ssh
> config rewriting) you need a networking-based abstraction so that
> all your services/programs deal with it, independent of their
> protocol.
Valid point, but this is not purely a networking problem. As I think
Richard alluded to in his brief response to my original post, there is
the USB repo case which requires switching between local filesystem
access (when the USB HDD is plugged into the local machine) and ssh
access (when it's plugged into another machine accessible via the
network). In that scenario, my URL rewriting suggestion works better
than any hack based on ssh config or DNS tricks. Sure, you could
point to localhost, but even going via ssh to the loopback interface
will be a significant performance hit vs. direct filesystem access.
By the way, I've improved my git-url-rewrite shell script to allow
reading of existing rules:
https://github.com/aspiers/git-config/blob/master/bin/git-url-rewrite
In the USB case, it's as simple as:
shorthost="${HOST%%.*}"
git url-rewrite $shorthost: $HOME/
git remote add $shorthost $shorthost:$repopath
assuming that the local mirror of the USB repo lives in
$HOME/$repopath.
More information about the vcs-home
mailing list