Created
March 9, 2010 03:33
-
-
Save sheepmaster/326122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| my $headref = `git symbolic-ref HEAD`; | |
| my $head; | |
| unless (($head) = ($headref =~ m!^refs/heads/(.*)!)) { | |
| die "invalid HEAD ref '$headref'"; | |
| } | |
| print STDERR "current branch: $head\n"; | |
| while (<>) { | |
| chomp; | |
| my ($old_ref, $new_ref, $refname) = split /\s/; | |
| my ($remote, $branch); | |
| if (($remote, $branch) = ($refname =~ m!^refs/remotes/([^/]+)/(.*)$!)) { | |
| if ($branch eq $head) { | |
| print STDERR "Merging $remote/$branch\n"; | |
| system("git merge --ff-only $remote/$branch"); | |
| } else { | |
| print STDERR "Ignoring update to $remote/$branch\n"; | |
| } | |
| } else { | |
| warn "Invalid ref update '$refname'\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment