summaryrefslogtreecommitdiff
path: root/sync-all
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-04-19 20:55:50 +0100
committerIan Lynagh <ian@well-typed.com>2013-04-19 20:58:44 +0100
commit561d64a851f1427233c93b6fceb24ef38bf64e70 (patch)
tree1cb691f938ea26aeb8a9b12d502ff0bf1ac8462e /sync-all
parent55c7a0d683bf657d4e490df428230824dac0f346 (diff)
downloadhaskell-561d64a851f1427233c93b6fceb24ef38bf64e70.tar.gz
Add a 'compare' command to sync-all
Diffstat (limited to 'sync-all')
-rwxr-xr-xsync-all47
1 files changed, 47 insertions, 0 deletions
diff --git a/sync-all b/sync-all
index 81bde320c7..741e22b2cb 100755
--- a/sync-all
+++ b/sync-all
@@ -506,6 +506,42 @@ sub gitall {
elsif ($command eq "tag") {
&git($localpath, "tag", @args);
}
+ elsif ($command eq "compare") {
+ # Don't compare the subrepos; it doesn't work properly as
+ # they aren't on a branch.
+ next if $remotepath eq "-";
+
+ my $compareto;
+ if ($#args eq -1) {
+ $compareto = $path;
+ }
+ elsif ($#args eq 0) {
+ $compareto = "$args[0]/$localpath";
+ }
+ elsif ($#args eq 1 && $args[0] eq "-b") {
+ $compareto = "$args[1]/$remotepath";
+ }
+ else {
+ die "Bad args for compare";
+ }
+ print "$localpath";
+ print (' ' x (40 - length($localpath)));
+ my $branch = &readgit($localpath, "rev-parse", "--abbrev-ref", "HEAD");
+ die "Bad branch: $branch"
+ unless $branch =~ /^[a-zA-Z][a-zA-Z0-9.-]*$/;
+ my $us = &readgit(".", "ls-remote", $localpath, "refs/heads/$branch");
+ my $them = &readgit(".", "ls-remote", $compareto, "refs/heads/$branch");
+ $us =~ s/[[:space:]].*//;
+ $them =~ s/[[:space:]].*//;
+ die "Bad commit of mine: $us" unless (length($us) eq 40);
+ die "Bad commit of theirs: $them" unless (length($them) eq 40);
+ if ($us eq $them) {
+ print "same\n";
+ }
+ else {
+ print "DIFFERENT\n";
+ }
+ }
else {
die "Unknown command: $command";
}
@@ -578,6 +614,17 @@ remote set-url [--push] <remote-name>
would point to the ghc repository, and for a remote repository it
points to the directory containing "ghc.git".
+compare
+compare reporoot
+compare -b reporoot
+
+ Compare the git HEADs of the repos to the origin repos, or the
+ repos under reporoot (which is assumde to be a checked-out tree
+ unless the -b flag is used).
+
+ 1 line is printed for each repo, indicating whether the repo is
+ at the "same" or a "DIFFERENT" commit.
+
These commands just run the equivalent git command on each repository, passing
any extra arguments to git: