On 2022/02/28 19:02, Marc Espie wrote:
> This kills both the generation and copying of $OpenBSD$ lines in update-patches.
>
> Main question is: are we okay generatin patches starting with Index: or
> do we want to leave an empty line (or something) reminding people to add
> an actual comment
>
> (that's the first chunk of the patch)
I think it's fine like that, but it could have some handling for
an empty second line in existing patches, as-is it keeps them,
so after a while we'll have a mixture of some files with an
empty first line and others with the comment or patch on the
first line.
Diff on top is not the prettiest but seems to do the trick.
--- update-patches.espie Mon Feb 28 22:09:41 2022
+++ update-patches Mon Feb 28 22:09:23 2022
@@ -216,8 +216,12 @@ sub parse_existing_patch
{
my $filename = shift;
open (my $f, '<', $filename) or die "can't read existing $filename: $!";
- my (@comment, $src, @patch);
+ my (@comment, $src, @patch, $skipifblank);
while (<$f>) {
+ if (m/^$/ and $skipifblank and $. == 2) {
+ $skipifblank = 0;
+ next;
+ }
if (m/^Index:\s+(\S.*)/) {
$src = $1;
while (<$f>) {
@@ -236,8 +240,12 @@ sub parse_existing_patch
}
last;
}
- next if $_ =~ m/^|^\$OpenBSD?/ and $. == 1;
+ if ($_ =~ m/^|^\$OpenBSD?/ and $. == 1) {
+ $skipifblank = 1;
+ next;
+ }
push(@comment, $_);
+ $skipifblank = 0;
}
return {stem => $src, filename => $filename,
comment => \@comment, patch => \@patch};
> Index: update-patches
> ===================================================================
> RCS file: /cvs/ports/infrastructure/bin/update-patches,v
> retrieving revision 1.21
> diff -u -p -r1.21 update-patches
> --- update-patches 9 Feb 2021 17:34:40 -0000 1.21
> +++ update-patches 28 Feb 2022 18:00:37 -0000
> @@ -206,12 +206,10 @@ sub create_patch
> die "diff exited with an error";
> }
> }
> - my $comment = "!OpenBSD!\n";
> - $comment =~ tr/!/$/;
> may_fuzz_patch($stem, \@lines);
> return {stem => $stem, patch => \@lines,
> filename => patch_name($stem),
> - comment => [$comment, "\n"] };
> + comment => [] };
> }
>
> sub parse_existing_patch
> @@ -238,6 +236,7 @@ sub parse_existing_patch
> }
> last;
> }
> + next if $_ =~ m/^|^\$OpenBSD?/ and $. == 1;
> push(@comment, $_);
> }
> return {stem => $src, filename => $filename,
>
No comments:
Post a Comment