diff options
-rw-r--r-- | debian/changelog | 1 | ||||
-rwxr-xr-x | dgit | 32 |
2 files changed, 22 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog index e0d986c..9082aad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -55,6 +55,7 @@ dgit (1.5~~) unstable; urgency=medium --quilt modes. * Fix two calls to chdir without proper error checking. * Fix a couple of bugs in error reporting. + * Fix up .orig detection to be less trustful of (ambiguous) filenames. Test suite: * When sbuild fails, do not crash due to sed not finding the log @@ -1429,12 +1429,20 @@ sub dsc_files () { map { $_->{Filename} } dsc_files_info(); } -sub is_orig_file ($;$) { - local ($_) = $_[0]; - my $base = $_[1]; - m/\.orig(?:-\w+)?\.tar\.\w+$/ or return 0; - defined $base or return 1; - return $` eq $base; +sub is_orig_file_in_dsc ($$) { + my ($f, $dsc_files_info) = @_; + return 0 if @$dsc_files_info <= 1; + # One file means no origs, and the filename doesn't have a "what + # part of dsc" component. (Consider versions ending `.orig'.) + return 0 unless $f =~ m/\.orig(?:-\w+)?\.tar(?:\.\w+)?$/; + return 1; +} + +sub is_orig_file_of_vsn ($$) { + my ($f, $upstreamvsn) = @_; + my $base = srcfn $upstreamvsn, ''; + return 0 unless $f =~ m/^\Q$base\E\.orig(?:-\w+)?\.tar(?:\.\w+)?$/; + return 1; } sub make_commit ($) { @@ -1523,7 +1531,8 @@ sub generate_commits_from_dsc () { prep_ud(); changedir $ud; - foreach my $fi (dsc_files_info()) { + my @dfi = dsc_files_info(); + foreach my $fi (@dfi) { my $f = $fi->{Filename}; die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#; @@ -1534,7 +1543,7 @@ sub generate_commits_from_dsc () { complete_file_from_dsc('.', $fi) or next; - if (is_orig_file($f)) { + if (is_orig_file_in_dsc($f, \@dfi)) { link $f, "../../../../$f" or $!==&EEXIST or die "$f $!"; @@ -1643,9 +1652,10 @@ sub complete_file_from_dsc ($$) { } sub ensure_we_have_orig () { - foreach my $fi (dsc_files_info()) { + my @dfi = dsc_files_info(); + foreach my $fi (@dfi) { my $f = $fi->{Filename}; - next unless is_orig_file($f); + next unless is_orig_file_in_dsc($f, \@dfi); complete_file_from_dsc('..', $fi) or next; } @@ -3754,7 +3764,7 @@ sub quilt_fixup_linkorigs ($$) { local ($debuglevel) = $debuglevel-1; printdebug "QF linkorigs $b, $f ?\n"; } - next unless is_orig_file $b, srcfn $upstreamversion,''; + next unless is_orig_file_of_vsn $b, $upstreamversion; printdebug "QF linkorigs $b, $f Y\n"; link_ltarget $f, $b or die "$b $!"; $fn->($b); |