Skip to content

Commit 238560e

Browse files
committed
Merge pull request openSUSE#198 from aspiers/fix-spec_add_patch-p1
Fix auto-detection of -p1 option to patch
2 parents 049f95c + 39bc571 commit 238560e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spec_add_patch

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,16 @@ for my $diffname (keys %diffs) {
138138
my $striplevel = "";
139139
open(P, '<', $diffname) or die "$diffname: $!\n";
140140
while(<P>) {
141-
$striplevel = " -p1" if (m/^--- a/ or m/^--- [^\/]+-\d+\./);
142-
last if (/^--- /);
141+
# Check if either the --- filename starts with 'a/' or the +++
142+
# filename starts with 'b/', or either starts with a package
143+
# name/version prefix. We have to check for either, because either
144+
# of them could be /dev/null if a file is being added or
145+
# deleted.
146+
$striplevel = " -p1"
147+
if m,^--- a/, or
148+
m,^\+\+\+ b/, or
149+
m,^(---|\+\+\+) [^/]+-\d+\.,;
150+
last if (/^@@ -\d/);
143151

144152
}
145153
close(P);

0 commit comments

Comments
 (0)