Package: devscripts
Version: 2.10.11
Severity: wishlist
Tags: patch

--- Please enter the report below this line. ---
debdiff uses interdiff for non-native packages (which have orig.tar.gz), but 
normal diff for native packages or when interdiff from patchutils is not 
installed.

When interdiff is being used, the output can be applied to a source package 
using "patch -p1", but otherwise you have to use "-p4".

The attached patch makes both methods compatible, by stripping the "common" 
path prefixes from the diff output.

Please note, that it could be done also by using "filterdiff --strip", but 
that would not cover the case when patchutils is not available.


The bug and patch has been initially posted for Ubuntu at: 
https://launchpad.net/bugs/136863
--- devscripts-2.10.11/scripts/debdiff.pl	2007-11-03 18:53:49.000000000 +0100
+++ /usr/bin/debdiff	2007-12-13 19:20:07.000000000 +0100
@@ -474,15 +474,28 @@
 	    }
 	    closedir(DIR);
 	}
-	my @command = ("diff", "-Nru");
-	for my $diff_opt (@diff_opts) {
-	    push @command, $diff_opt;
-	}
+	my @command = ("diff", "-Nru", @diff_opts);
 	for my $exclude (@excludes) {
 	    push @command, ("--exclude", $exclude);
 	}
 	push @command, ("$dir1/$sdir1", "$dir2/$sdir2");
-	system @command;
+
+	# Execute diff and remove the common prefixes $dir1/$dir2, so the patch can be used with -p1,
+	# as if when interdiff would have been used:
+	open( DIFF, '-|', @command ) || fatal "Failed to execute @command!";
+
+	# replace in first line:
+	my $first = <DIFF>;
+	$first =~ s/ $dir1\/$sdir1/ $sdir1/;
+	$first =~ s/ $dir2\/$sdir2/ $sdir2/;
+	print $first;
+
+	while(<DIFF>) {
+		s/^--- $dir1\//--- /;
+		s/^\+\+\+ $dir2\//+++ /;
+		print;
+ 	}
+	close DIFF;
     }
 
     exit 0;

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to