my $last_touch = time;
my(@patches, %local_patch);
-if (@ARGV) {
- foreach (@ARGV) {
- s{^(patches|patch|origin/patch)/} {};
- s{\.diff$} {};
- push(@patches, $_);
- }
- open(PIPE, '-|', 'git', 'branch', '-l') or die $!;
-} else {
- open(PIPE, '-|', 'git', 'branch', '-a') or die $!;
-}
+
+# 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);
$description{$patch} = $desc;
}
+if (@ARGV) {
+ # Limit the list of patches to actually process based on @ARGV.
+ @patches = ( );
+ foreach (@ARGV) {
+ s{^(patches|patch|origin/patch)/} {};
+ s{\.diff$} {};
+ push(@patches, $_);
+ }
+}
+
my %completed;
foreach my $patch (@patches) {
next if $completed{$patch}++;
}
sleep 1 if $last_touch == time;
-system "git checkout master" and die $!;
+system "git checkout master" and exit 1;
exit;
open(OUT, '>', "$patches_dir/$patch.diff") or die $!;
print OUT $description{$patch}, "\n";
- if (system("git rebase -m $parent") != 0) {
- print qq|"git rebase -m $parent" incomplete -- please fix.\n|;
+ if (system("git merge $parent") != 0) {
+ print qq|"git merge $parent" incomplete -- please fix.\n|;
$ENV{PS1} = "[$parent] patch/$patch: ";
system $ENV{SHELL} and exit 1;
}
die <<EOT;
Usage: patch-update [OPTIONS]
---gen[=DIR] Inlcude generated files.
---skip-check Skip the master-branch, clean-checkout check.
+--gen[=DIR] Include generated files. Optional dest DIR overrides "patches".
+--skip-check Skip the check that ensures starting with a clean master branch.
EOT
}