[commit: ghc] master: sync-all: infer remotepath from .gitmodules file (72fe49d)

git at git.haskell.org git at git.haskell.org
Thu Jun 26 02:54:42 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/72fe49d88565fc1dd807a0e185a5aa6fc4989ea0/ghc

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

commit 72fe49d88565fc1dd807a0e185a5aa6fc4989ea0
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Tue Jun 17 17:27:04 2014 +0200

    sync-all: infer remotepath from .gitmodules file
    
    After this commit, running `sync-all remote set-url` works properly for the
    haddock package:
    
        command: ./sync-all -r git://git.haskell.org remote set-url origin
        before: git://git.haskell.org/packages/haddock.git
        after: git://git.haskell.org/haddock.git
    
    By doing the `remotepath` lookup before the `$is_github_repo` check,
    running `sync-all remote set-url` now also works properly for submodule
    repos on github:
    
        command: ./sync-all -r git://github.com/ghc remote set-url origin
        before: git://github.com/ghc/packages/binary
        after: git://github.com/ghc/packages-binary
    
    * Relevant prior commits:
    4f4357 "Make `sync-all remote set-url` use normalized `/packages/` urls"
    34b072 "Convert haddock into a proper submodule (re #8545)"
    974a97 "sync-all: Apply submodule url rewriting also to stuff in util/"


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

72fe49d88565fc1dd807a0e185a5aa6fc4989ea0
 sync-all | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/sync-all b/sync-all
index 88c40da..e68da62 100755
--- a/sync-all
+++ b/sync-all
@@ -315,8 +315,6 @@ sub gitall {
         # Use the "remote" structure for bare git repositories
         $localpath  = ($bare_flag) ?
                       $$line{"remotepath"} : $$line{"localpath"};
-        $remotepath = ($checked_out_tree) ?
-                      $$line{"localpath"}  : $$line{"remotepath"};
 
         if (!$started) {
             if ($start_repo eq $localpath) {
@@ -335,6 +333,17 @@ sub gitall {
 
         $repo_is_submodule = $$line{"remotepath"} eq "-";
 
+        if ($checked_out_tree) {
+            $remotepath = $$line{"localpath"};
+        }
+        elsif ($repo_is_submodule) {
+            $remotepath = &readgitline(".", 'config', '-f', '.gitmodules', '--get', "submodule.$localpath.url");
+            $remotepath =~ s/\.\.\///;
+        }
+        else {
+            $remotepath = $$line{"remotepath"};
+        }
+
         # We can't create directories on GitHub, so we translate
         # "packages/foo" into "package-foo".
         if ($is_github_repo) {
@@ -457,30 +466,15 @@ sub gitall {
         }
         elsif ($command eq "remote") {
             my @scm_args;
-            my $rpath;
             $ignore_failure = 1;
-            if ($repo_is_submodule) {
-                $rpath = "$localpath.git"; # N.B.: $localpath lacks the .git suffix
-                if ($localpath =~ m!^(?:libraries|utils)/!) {
-                    # FIXME: This is just a simple heuristic to
-                    # infer the remotepath for Git submodules. A
-                    # proper solution would require to parse the
-                    # .gitmodules file to obtain the actual
-                    # localpath<->remotepath mapping.
-                    $rpath =~ s!^(?:libraries|utils)/!packages/!;
-                }
-                $rpath = "$repo_base/$rpath";
-            } else {
-                $rpath = $path;
-            }
             if ($subcommand eq 'add') {
-                @scm_args = ("remote", "add", $branch_name, $rpath);
+                @scm_args = ("remote", "add", $branch_name, $path);
             } elsif ($subcommand eq 'rm') {
                 @scm_args = ("remote", "rm", $branch_name);
             } elsif ($subcommand eq 'set-branches') {
                 @scm_args = ("remote", "set-branches", $branch_name);
             } elsif ($subcommand eq 'set-url') {
-                @scm_args = ("remote", "set-url", $branch_name, $rpath);
+                @scm_args = ("remote", "set-url", $branch_name, $path);
             }
             &git($localpath, @scm_args, @args);
         }



More information about the ghc-commits mailing list