Re: Access different NAMESPACE of remote repo from client side

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2013/11/15 Sitaram Chamarty <sitaramc@xxxxxxxxx>:
> On 11/15/2013 07:55 PM, Sitaram Chamarty wrote:
>> On 11/15/2013 01:49 PM, Jiang Xin wrote:
>>> Just like solution 2, these settings won't work without a patched
>>> git-shell or gitolite.
>>
>> Gitolite has a namespaces branch that handles namespaces as described in
>> http://gitolite.com/gitolite/namespaces.html
>>
>> Briefly, it recognises that you can have a "main" repo off of which
>> several developer might want to hang their logical repos.
>>
>> It also recognises that the actual names of the logical repos will
>> follow some pattern that may include the name of the developer also, and
>> provides a way to derive the name of the physical repo from the logical
>> one.
>>
>> There is an example or two in that link.

I use gitolite everyday, and thank you for inventing it. I use gitolite v2 for
a long time, and migrated to v3 recently. Thank you for pointing out
there is a "namespace" feature branch, and I love the implementation
very much, it is so easy to map logical repos to one physical repo.

>
> I should add that the Gitolite model is: the user doesn't need to know
> about namespaces, because namespaces are just things that the server
> admin is setting up for his own reasons...
>

I want to say something that git-namespace is sometimes significant
for normal user not only for admin.

Some of my repos are managed by Topgit. With the help of topgit,
dependance of the topic branch (usually named as "t/feature-name")
are tracked by file ".topdeps" and a special ref named as
"refs/top-bases/t/feature-name". So there are many topic branches
and many useful special refs.

Every time when I want to update all topic branches to the new
upstream version, just before run "tg update", I want to take a
snapshoot of all branches and refs. Clone is heavy, so I want to use
light-weight namespace.

If the server is out of my control, it would be nice to let the user pass
namespace to the server from client side.

Indeed, I patched gitolite first as the follows, than I find out git-shell
needs to be patched too.


diff --git a/src/gitolite-shell b/src/gitolite-shell
index 7a27cc0..1c957da 100755
--- a/src/gitolite-shell
+++ b/src/gitolite-shell
@@ -101,7 +101,7 @@ sub main {
     my $user = $ENV{GL_USER} = shift @ARGV;

     # set up the repo and the attempted access
-    my ( $verb, $repo ) = parse_soc();    # returns only for git commands
+    my ( $verb, $option, $repo ) = parse_soc();    # returns only for
git commands
     sanity($repo);
     $ENV{GL_REPO} = $repo;
     my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
@@ -135,7 +135,11 @@ sub main {
         _system( "git", "http-backend" );
     } else {
         my $repodir = "'$rc{GL_REPO_BASE}/$repo.git'";
-        _system( "git", "shell", "-c", "$verb $repodir" );
+        my $cmd = $verb;
+        if ($option) {
+            $cmd =~ s/^(git)[- ](.*)$/$1 $option $2/;
+        }
+        _system( "git", "shell", "-c", "$cmd $repodir" );
     }
     trigger( 'POST_GIT', $repo, $user, $aa, 'any', $verb );
 }
@@ -146,13 +150,24 @@ sub parse_soc {
     my $soc = $ENV{SSH_ORIGINAL_COMMAND};
     $soc ||= 'info';

-    my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
-    if ( $soc =~ m(^($git_commands) '/?(.*?)(?:\.git(\d)?)?'$) ) {
-        my ( $verb, $repo, $trace_level ) = ( $1, $2, $3 );
+    my $git_commands = "upload-pack|receive-pack|upload-archive";
+    my ( $verb, $option, $repo, $trace_level );
+    if ( $soc =~
m(^git\s+(?:(--namespace)(?:=|\s+)(\S+)\s+)?(\S+)\s+'/?(.*?)(?:\.git(\d)?)?'$)
) {
+        $option = "$1=$2";
+        $verb = "git-$3";
+        $repo = $4;
+        $trace_level = $5;
+    } elsif ( $soc =~ m(^git[- ]($git_commands) '/?(.*?)(?:\.git(\d)?)?'$) ) {
+        $verb = "git-$1";
+        $repo = $2;
+        $trace_level = $3;
+    }
+
+    if ($verb) {
         $ENV{D} = $trace_level if $trace_level;
         _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
         trace( 2, "git command", $soc );
-        return ( $verb, $repo );
+        return ( $verb, $option, $repo );
     }

     # after this we should not return; caller expects us to handle it all here



-- 
Jiang Xin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]