[commit: ghc] master: Teach sync-all how to rewrite submodule repo urls (0481e07)

git at git.haskell.org git at git.haskell.org
Sat Sep 28 10:20:39 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/0481e076f3cb4010894324cac71e947c6637805a/ghc

>---------------------------------------------------------------

commit 0481e076f3cb4010894324cac71e947c6637805a
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sat Sep 28 10:15:21 2013 +0200

    Teach sync-all how to rewrite submodule repo urls
    
    This applies attachment:sync-all-submodules-locally.diff from #8369
    
    Authored-by: Nathaniel Filardo
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>


>---------------------------------------------------------------

0481e076f3cb4010894324cac71e947c6637805a
 sync-all |   29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/sync-all b/sync-all
index 1124524..2789667 100755
--- a/sync-all
+++ b/sync-all
@@ -176,6 +176,7 @@ sub getrepo {
 
     my $repo_base;
     my $checked_out_tree;
+    my $repo_local = 0;
 
     if ($repo =~ /^...*:/) {
         # HTTP or SSH
@@ -206,6 +207,7 @@ sub getrepo {
     }
     elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
         # Local filesystem, either absolute (C:/ or /) or relative (../) path
+        $repo_local = 1;
         $repo_base = $repo;
         if (-f "$repo/HEAD") {
             # assume a local mirror:
@@ -223,7 +225,7 @@ sub getrepo {
         die "Couldn't work out repo";
     }
 
-    return $repo_base, $checked_out_tree;
+    return $repo_base, $checked_out_tree, $repo_local;
 }
 
 sub gitall {
@@ -244,7 +246,7 @@ sub gitall {
     my $doing;
     my $start_repo;
 
-    my ($repo_base, $checked_out_tree) = getrepo();
+    my ($repo_base, $checked_out_tree, $repo_local) = getrepo();
 
     my $is_github_repo = $repo_base =~ m/(git@|git:\/\/|https:\/\/)github.com/;
 
@@ -561,6 +563,22 @@ sub gitall {
     unlink "resume";
 }
 
+sub gitInitSubmodules {
+    &git(".", "submodule", "init", @_);
+
+    my ($repo_base, $checked_out_tree, $repo_local) = getrepo();
+    # if we came from a local repository, grab our submodules from their
+    # checkouts over there, if they exist.
+    if ($repo_local) {
+        my $gitConfig = &tryReadFile(".git/config");
+        foreach $_ (split /^/, $gitConfig) {
+            if ($_ =~ /^\[submodule "(.*)"\]$/ and -e "$repo_base/$1/.git") {
+                &git(".", "config", "submodule.$1.url", "$repo_base/$1");
+            }
+        }
+    }
+}
+
 sub checkCurrentBranchIsMaster {
     my $branch = `git symbolic-ref HEAD`;
     $branch =~ s/refs\/heads\///;
@@ -892,18 +910,19 @@ sub main {
         my @submodule_args = grep(/^-q/, at _);
 
         if ($command eq "get") {
-            &git(".", "submodule", "init", @submodule_args);
+            &gitInitSubmodules(@submodule_args);
         }
+
         if ($command eq "pull") {
             my $gitConfig = &tryReadFile(".git/config");
             if ($gitConfig !~ /submodule/) {
-                &git(".", "submodule", "init", @submodule_args);
+                &gitInitSubmodules(@submodule_args);
             }
         }
         if ($command eq "get" or $command eq "pull") {
             my $gitConfig = &tryReadFile(".git/config");
             if ($gitConfig !~ /submodule/) {
-                &git(".", "submodule", "init", @submodule_args);
+                &gitInitSubmodules(@submodule_args);
             }
             &git(".", "submodule", "update", @submodule_args);
         }




More information about the ghc-commits mailing list