diff --git a/scripts/patch-tag b/scripts/patch-tag index 7db3cfd..b0db0c5 100755 --- a/scripts/patch-tag +++ b/scripts/patch-tag @@ -89,9 +89,6 @@ my $VERSION = "0.11"; my $default_comment = "from:subject:patch-mainline:Git-commit:references:signed-off-by:acked-by:reviewed-by:"; my $post_comment_tags = "signed-off-by acked-by reviewed-by"; -# when these are in the bk comment, and non-bk section, use the non-bk one -my $non_dup_tags = "from subject"; - # command line options my %tags; # hash of tags to be replaced my %print_tags; # hash of tags for printing to stdout @@ -109,7 +106,6 @@ my $replace_empty_comment; # new value for empty non-tag comment # globals my @output_array; # the finished comment as printed my @all_tags; # array used to do final tag output -my @bk_footer_tags; # holds signed-off-by and acked-by from bk my %replaced_tags; # copy of %tags so we can detect which ones are found my $replace = 0; # should we overwrite the patch file? my $outfh; # current output file handle (could be a temp file) @@ -197,40 +193,15 @@ sub process_tag($$) { delete $replaced_tags{$t}; } -# tags that get pulled from bk comments get special treatment -sub process_bk_tag($$) { - my ($tag, $value) = @_; - my $always_tags = "signed-off-by acked-by reviewed-by"; - - if ($always_tags =~ m/$tag/) { - push @bk_footer_tags, [$tag, $value]; - return; - } - # don't pull the bk tag out if it already exists - foreach my $v (@all_tags) { - $v =~ m/$tag_re/; - my $t = $1; - if (lc($t) eq $tag) { - return; - } - } - $replaced_tags{$tag} = $value; -} - # look for any tags that we were asked to print or replace from # the command line. Build the array of tags found in the comment sub check_tags($$$) { my ($infh, $buf, $line) = @_; - my $filespec = ""; - my $bk_comment = 0; my $orig_line; - my $bkold_style = 0; again: $orig_line = $line; - if ($bk_comment) { - $line =~ s/^#\s*//; - } + # Preserve git From line if ($line =~ m/$git_re/) { push @output_array, $orig_line; @@ -246,77 +217,9 @@ again: $line =~ m/(^[^:\s#]*):\s*(.*)/s; my $lc_tag = lc($1); my $value = $2; - if ($bk_comment) { - # only pull out specific tags from the bk comment stream - if ($post_comment_tags =~ m/$lc_tag/) { - process_bk_tag($lc_tag, $value); - } - if (!%print_tags) { - push @output_array, $orig_line; - } - } else { - process_tag($lc_tag, $value); - } + process_tag($lc_tag, $value); } elsif (!%print_tags) { push @output_array, $orig_line; - } - # did we find a bitkeeper style patch header? - # if so, just parse the whole thing here - if ($line =~ m/^# The following is the BitKeeper ChangeSet Log/ || - $line =~ m/^# This is a BitKeeper generated diff -Nru style patch/) { - # there are two bk patch styles - # old: - # # ------------------- - # # date author changset - # # subject - # new: - # # - # # Changeset - # # date time author - # # subject - - $bk_comment = 1; - my $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - if ($next =~ m/^# ---------/) { - $bkold_style = 1; - } else { - # read empty line - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - } - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - my @words = split /\s+/, $next; - if ($bkold_style) { - process_bk_tag('from', $words[2]); - } else { - process_bk_tag('from', $words[3]); - } - $next = read_next_line($infh, $buf); - push @output_array, $next if (!%print_tags); - chomp($next); - $next =~ s/^#\s*//; - # sometimes the bk comment is empty and there is just a filename - # there's no good way to tell. - if (!($next =~ m/(.*\/)+?.*?\.(c|h|s)$/)) { - process_bk_tag('subject', $next); - } - - # we've read the from tag and subject tag, the goto again - # will loop through the ChangeSet Log section looking - # for other tags - } - if ($bk_comment) { - $line = read_next_line($infh, $buf); - # old style bk comments end with a line full of dashes - # new style bk comments end with a # filename or no # at all - if (($bkold_style && $line =~ m/^# --------/) || - (!$bkold_style && $line =~ m/^# \S|^[^#]/)) { - push @$buf, $line; - return; - } - goto again; } } @@ -645,7 +548,6 @@ foreach my $guarded_input (@files) { %replaced_tags = (%tags, %add_tags); @all_tags = (); @output_array = (); - @bk_footer_tags = (); my %tmp_always_add = %always_add_tags; if ($replace) { @@ -679,9 +581,6 @@ foreach my $guarded_input (@files) { while($output_array[scalar(@output_array)-1] =~ m/^\s*\n$/) { pop @output_array; } - foreach my $h (@bk_footer_tags) { - process_tag($h->[0], $h->[1]); - } # add any new tags left over, but do From and Subject first add_output_tag('from', \%replaced_tags); add_output_tag('subject', \%replaced_tags);