[commit: ghc] master: sync-all: cleanup (4612524)

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


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/4612524542e26c782e8e1255b6e323c704310b56/ghc

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

commit 4612524542e26c782e8e1255b6e323c704310b56
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Wed Jun 11 15:36:45 2014 +0200

    sync-all: cleanup
    
    + Remove dead code from the DarcsAges
    + Tweak `git config` flags
        * remove --local, it is not a valid flag
        * --get was used in some places, not in others
    + Simplify reading current branch
    + Delete duplicated code in help


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

4612524542e26c782e8e1255b6e323c704310b56
 sync-all | 50 +++++++++-----------------------------------------
 1 file changed, 9 insertions(+), 41 deletions(-)

diff --git a/sync-all b/sync-all
index ffc150e..e0e1f55 100755
--- a/sync-all
+++ b/sync-all
@@ -16,7 +16,6 @@ my $verbose = 2;
 my $try_to_resume = 0;
 my $ignore_failure = 0;
 my $checked_out_flag = 0; # NOT the opposite of bare_flag (describes remote repo state)
-my $get_mode;
 my $bare_flag = ""; # NOT the opposite of checked_out_flag (describes local repo state)
 
 my %tags;
@@ -159,11 +158,11 @@ sub readgit {
 sub configure_repository {
     my $localpath = shift;
 
-    &git($localpath, "config", "--local", "core.ignorecase", "true");
+    &git($localpath, "config", "core.ignorecase", "true");
 
     my $autocrlf = &readgitline($localpath, 'config', '--get', 'core.autocrlf');
     if ($autocrlf eq "true") {
-        &git($localpath, "config", "--local", "core.autocrlf", "false");
+        &git($localpath, "config", "core.autocrlf", "false");
         &git($localpath, "reset", "--hard");
     }
 }
@@ -182,14 +181,14 @@ sub getrepo {
         my $branch = &readgitline($git_dir, "rev-parse", "--abbrev-ref", "HEAD");
         die "Bad branch: $branch"
             unless $branch =~ m!^[a-zA-Z][a-zA-Z0-9./-]*$!;
-        my $remote = &readgitline($git_dir, "config", "branch.$branch.remote");
+        my $remote = &readgitline($git_dir, "config", "--get", "branch.$branch.remote");
         if ($remote eq "") {
             # remotes are not mandatory for branches (e.g. not recorded by default for bare repos)
             $remote = "origin";
         }
         die "Bad remote: $remote"
             unless $remote =~ m!^[a-zA-Z][a-zA-Z0-9./-]*$!;
-        $repo = &readgitline($git_dir, "config", "remote.$remote.url");
+        $repo = &readgitline($git_dir, "config", "--get", "remote.$remote.url");
     }
 
     my $repo_base;
@@ -204,11 +203,7 @@ sub getrepo {
 
         # --checked-out is needed if you want to use a checked-out repo
         # over SSH or HTTP
-        if ($checked_out_flag) {
-            $checked_out_tree = 1;
-        } else {
-            $checked_out_tree = 0;
-        }
+        $checked_out_tree = $checked_out_flag;
 
         # Don't drop the last part of the path if specified with -r, as
         # it expects repos of the form:
@@ -604,9 +599,7 @@ sub gitInitSubmodules {
 }
 
 sub checkCurrentBranchIsMaster {
-    my $branch = `git symbolic-ref HEAD`;
-    $branch =~ s/refs\/heads\///;
-    $branch =~ s/\n//;
+    my $branch = &readgitline(".", "rev-parse", "--abbrev-ref", "HEAD");
 
     if ($branch !~ /master/) {
         print "\nWarning: You are trying to 'pull' while on branch '$branch'.\n"
@@ -621,8 +614,7 @@ sub help
 
         my $tags = join ' ', sort (grep !/^-$/, keys %tags);
 
-        # Get the built in help
-        my $help = <<END;
+        print <<END;
 Usage:
 
 ./sync-all [-q] [-s] [--ignore-failure] [-r repo] [--checked-out] [--bare]
@@ -790,30 +782,9 @@ sync-all *ignores* the defaultrepo of all repos other than the root one. So the
 remote repos must be laid out in one of the two formats given by <local-path>
 and <remote-path> in the file 'packages'.
 
-Available package-tags are:
-END
-
-        # Collect all the tags in the packages file
-        my %available_tags;
-        open IN, "< packages.conf"
-            or open IN, "< packages" # clashes with packages directory when using --bare
-            or die "Can't open packages file (or packages.conf)";
-        while (<IN>) {
-            chomp;
-            if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)/) {
-                if (defined($2) && $2 ne "-") {
-                    $available_tags{$2} = 1;
-                }
-            }
-            elsif (! /^(#.*)?$/) {
-                die "Bad line: $_";
-            }
-        }
-        close IN;
+Available package-tags are: $tags
 
-        # Show those tags and the help text
-        my @available_tags = keys %available_tags;
-        print "$help at available_tags\n\n";
+END
         exit $exit;
 }
 
@@ -846,9 +817,6 @@ sub main {
         elsif ($arg eq "--ignore-failure") {
             $ignore_failure = 1;
         }
-        elsif ($arg eq "--complete" || $arg eq "--partial") {
-            $get_mode = $arg;
-        }
         # Use --checked-out if the _remote_ repos are a checked-out tree,
         # rather than the master trees.
         elsif ($arg eq "--checked-out") {



More information about the ghc-commits mailing list