chiark / gitweb /
Make access_giturl be capable of being optional, and use this feature when cloning...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 29 Oct 2014 21:54:34 +0000 (21:54 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 8 Nov 2014 16:16:57 +0000 (16:16 +0000)
dgit

diff --git a/dgit b/dgit
index 25afa6734dfebd9a692c524954a537e2b847dfcc..fa09ca35be8f536a5a31093a5dbd611e29c00b72 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -638,11 +638,14 @@ sub access_gituserhost () {
     return access_someuserhost('git');
 }
 
-sub access_giturl () {
+sub access_giturl (;$) {
+    my ($optional) = @_;
     my $url = access_cfg('git-url','RETURN-UNDEF');
     if (!defined $url) {
+       my $proto = access_cfg('git-proto', 'RETURN-UNDEF');
+       return undef unless defined $proto;
        $url =
-           access_cfg('git-proto').
+           $proto.
            access_gituserhost().
            access_cfg('git-path');
     }
@@ -1326,11 +1329,14 @@ sub clone ($) {
     mkdir $dstdir or die "$dstdir $!";
     changedir $dstdir;
     runcmd @git, qw(init -q);
-    runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
-    open H, "> .git/HEAD" or die $!;
-    print H "ref: ".lref()."\n" or die $!;
-    close H or die $!;
-    runcmd @git, qw(remote add), 'origin', access_giturl();
+    my $giturl = access_giturl(1);
+    if (defined $giturl) {
+       runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
+       open H, "> .git/HEAD" or die $!;
+       print H "ref: ".lref()."\n" or die $!;
+       close H or die $!;
+       runcmd @git, qw(remote add), 'origin', $giturl;
+    }
     if (check_for_git()) {
        progress "fetching existing git history";
        git_fetch_us();