Created
March 31, 2010 10:59
-
-
Save sheepmaster/350197 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`; | |
| if (my ($head) = ($headref =~ m!^refs/heads/(.*)!)) { | |
| my $fh; | |
| unless (open($fh, '-|', qw[git branch -r --no-merge HEAD])) { | |
| print STDERR "Couldn't execute 'git branch -r --no-merge HEAD': $!\n"; | |
| exit(1); | |
| } | |
| my @branches; | |
| while (<$fh>) { | |
| chomp; | |
| if (my ($branch) = m!^\s+([^/]+/\Q$head\E)$!) { | |
| push(@branches, $branch); | |
| } | |
| } | |
| if (@branches) { | |
| print STDERR "git merge ", join(' ', @branches), "\n"; | |
| (system(qw[git merge], @branches) == 0) or die $!; | |
| } else { | |
| print STDERR "Already up-to-date.\n"; | |
| } | |
| } else { | |
| print STDERR "HEAD is at '$headref', which doesn't look like a branch\n"; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment