Patrick Palka wrote:

> I think the branch check should only be done when performing a pull
> command. That way one can still do ./sync-all fetch, ./sync-all diff, etc
> when on a separate branch.

Yes, that makes sense. Updated patch attached.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
>From 00c7fbaf0caff710aa0c48a3e7be564e9a91a728 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <er...@mega-nerd.com>
Date: Sun, 4 Aug 2013 16:33:27 +1000
Subject: [PATCH] sync-all : Bail out of 'pull' operation if not on master
 branch.

---
 sync-all | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sync-all b/sync-all
index fc629df..5da88c7 100755
--- a/sync-all
+++ b/sync-all
@@ -551,6 +551,17 @@ sub gitall {
     unlink "resume";
 }
 
+sub assertCurrentBranchIsMaster {
+    my $branch = `git symbolic-ref HEAD` ;
+    $branch =~ s/refs\/heads\/// ;
+    $branch =~ s/\n// ;
+
+    if ($branch !~ /master/) {
+        die "\nError: You trying to 'pull' while on branch '$branch'.\n"
+          . "To perform a 'pull' you should switch back to the master branch first.\n\n"
+    }
+}
+
 sub help
 {
         my $exit = shift;
@@ -889,6 +900,9 @@ sub main {
 }
 
 BEGIN {
+    if ("pull" ~~ @ARGV) {
+        assertCurrentBranchIsMaster();
+    }
     $initial_working_directory = getcwd();
 }
 
-- 
1.8.4.rc1

_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to