chiark / gitweb /
dgit-repos-server: Handle ' ' in SSH_ORIGINAL_COMMAND (which some git versions send...
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 57159b70fd62cdba67c3568736bdd594ccd6221f..38b02e4e1b4ca07f8163b9e0ad440a2df0d1b24b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -102,6 +102,7 @@ our $remotename = 'dgit';
 our @ourdscfield = qw(Dgit Vcs-Dgit-Master);
 our $branchprefix = 'dgit';
 our $csuite;
+our $instead_distro;
 
 sub lbranch () { return "$branchprefix/$csuite"; }
 my $lbranch_re = '^refs/heads/'.$branchprefix.'/([^/.]+)$';
@@ -595,6 +596,7 @@ sub access_distros () {
     # Returns list of distros to try, in order
     #
     # We want to try:
+    #    0. `instead of' distro name(s) we have been pointed to
     #    1. the access_quirk distro, if any
     #    2a. the user's specified distro, or failing that  } basedistro
     #    2b. the distro calculated from the suite          }
@@ -602,6 +604,7 @@ sub access_distros () {
 
     my (undef,$quirkdistro) = access_quirk();
     unshift @l, $quirkdistro;
+    unshift @l, $instead_distro;
     return grep { defined } @l;
 }
 
@@ -661,7 +664,9 @@ sub access_runeinfo ($) {
 
 sub access_someuserhost ($) {
     my ($some) = @_;
-    my $user = access_cfg("$some-user",'username');
+    my $user = access_cfg("$some-user-force", 'RETURN-UNDEF');
+    defined($user) && length($user) or
+       $user = access_cfg("$some-user",'username');
     my $host = access_cfg("$some-host");
     return length($user) ? "$user\@$host" : $host;
 }
@@ -975,6 +980,7 @@ sub get_archive_dsc () {
     $dsc = undef;
 }
 
+sub check_for_git ();
 sub check_for_git () {
     # returns 0 or 1
     my $how = access_cfg('git-check');
@@ -985,6 +991,14 @@ sub check_for_git () {
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
+       if ($r =~ m/^divert (\w+)$/) {
+           my $divert=$1;
+           my ($usedistro,) = access_distros();
+           $instead_distro= cfg("dgit-distro.$usedistro.diverts.$divert");
+           $instead_distro =~ s{^/}{ access_basedistro()."/" }e;
+           printdebug "diverting $divert so using distro $instead_distro\n";
+           return check_for_git();
+       }
        failedcmd @cmd unless $r =~ m/^[01]$/;
        return $r+0;
     } elsif ($how eq 'true') {