X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/f2b7b64d867240f219fba74e5f30020bdec335d6..a5e0bf35795dde0e5f9b509ba09d9e28dbfb530b:/support/patch-update diff --git a/support/patch-update b/support/patch-update index 2d073565..f6eb47fe 100755 --- a/support/patch-update +++ b/support/patch-update @@ -27,13 +27,13 @@ if (defined $incl_generated_files) { 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('', ); +close IN; unless ($skip_branch_check) { - open(IN, '-|', 'git status') or die $!; - my $status = join('', ); - 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"; @@ -55,26 +55,21 @@ if ($incl_generated_files) { } 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 $!; -} +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 () { 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"; @@ -93,6 +88,16 @@ foreach my $patch (@patches) { $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}++; @@ -104,7 +109,7 @@ if ($incl_generated_files) { } sleep 1 if $last_touch == time; -system "git checkout master" and die $!; +system "git checkout $starting_branch" and exit 1; exit; @@ -135,8 +140,8 @@ sub update_patch 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; } @@ -181,7 +186,7 @@ sub usage die <