summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2022-09-02 19:19:14 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2022-09-03 18:12:46 +0100
commit021c3ce3426825731a94ce0312da16c70d84c5df (patch)
tree49ed9c33997a760c3a920edce18547676b2e0f1e
parent330eeb5cbc8dcd3bf7df790399e50256983f6847 (diff)
dgit: unrepresentable check: Normalise the mode for exec
Now we use git diffs, which can represent changes to the executability of files. dpkg-source uses diff(1) to apply these. So it all works. Handle this by normalising the +x bits before seeing if the mode changed. Now we properly support executable files. Closes: #995056 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-xdgit9
-rwxr-xr-xtests/tests/unrepresentable2
2 files changed, 9 insertions, 2 deletions
diff --git a/dgit b/dgit
index 3933cec..9079ef3 100755
--- a/dgit
+++ b/dgit
@@ -5411,6 +5411,11 @@ END
close S or confess "$!";
}
+sub normalise_mode_strip_exec ($) {
+ my ($m) = @_;
+ return $m eq '100755' ? '100644' : $m;
+}
+
sub quiltify_trees_differ ($$;$$$) {
my ($x,$y,$finegrained,$ignorenamesr,$unrepres) = @_;
# returns true iff the two tree objects differ other than in debian/
@@ -5448,7 +5453,9 @@ sub quiltify_trees_differ ($$;$$$) {
if ($oldmode =~ m/[^0]/ &&
$newmode =~ m/[^0]/) {
# both old and new files exist
- die __ "mode or type changed\n" if $oldmode ne $newmode;
+ die __ "mode or type changed in unsupported way\n" if
+ normalise_mode_strip_exec($oldmode) ne
+ normalise_mode_strip_exec($newmode);
die __ "modified symlink\n" unless $newmode =~ m/^10/;
} elsif ($oldmode =~ m/[^0]/) {
# deletion
diff --git a/tests/tests/unrepresentable b/tests/tests/unrepresentable
index fa1f985..70f7f78 100755
--- a/tests/tests/unrepresentable
+++ b/tests/tests/unrepresentable
@@ -132,7 +132,7 @@ finish GOOD:'deleted unwritable' LATE-EP:'Mode change from 644 to 000000'
start src.c
chmod +x src.c
git add src.c
-finish 'EP:mode or type changed' LATE-EP:'Mode change from 644 to 755'
+finish GOOD:chmod LATE-EP:'Mode change from 644 to 755'
start newx
echo hi >newx