die "No '$patches_dir' directory was found.\n" unless -d $patches_dir;
die "No '.git' directory present in the current dir.\n" unless -d '.git';
+open(IN, '-|', 'git status') or die $!;
+my $status = join('', <IN>);
+close IN;
unless ($skip_branch_check) {
- open(IN, '-|', 'git status') or die $!;
- my $status = join('', <IN>);
- close IN;
die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
- die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
}
+my($starting_branch) = $status =~ /^# On branch (.+)\n/;
my @extra_files;
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
}
my $last_touch = time;
-my(@patches, %local_patch);
+my(%patches, %local_patch);
# Start by finding all patches so that we can load all possible parents.
open(PIPE, '-|', 'git', 'branch', '-a') or die $!;
while (<PIPE>) {
if (m# origin/patch/(.*)#) {
- push(@patches, $1);
+ $patches{$1} = 1;
} elsif (m# patch/(.*)#) {
- $local_patch{$1} = 1;
+ $patches{$1} = $local_patch{$1} = 1;
}
}
close PIPE;
+my @patches = sort keys %patches;
+
my(%parent, %description);
foreach my $patch (@patches) {
my $branch = ($local_patch{$patch} ? '' : 'origin/') . "patch/$patch";
}
sleep 1 if $last_touch == time;
-system "git checkout master" and exit 1;
+system "git checkout $starting_branch" and exit 1;
exit;
Usage: patch-update [OPTIONS]
--gen[=DIR] Include generated files. Optional dest DIR overrides "patches".
---skip-check Skip the check that ensures starting with a clean master branch.
+--skip-check Skip the check that ensures starting with a clean branch.
EOT
}