diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-09-06 14:44:15 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2016-09-28 08:51:18 +0000 |
commit | 99283bb2c4470ee2977c3050e467fa0c1d477ab2 (patch) | |
tree | ddc5f30193e1c17c859e87a85c3d63ba8a8ea950 /git-hooks | |
parent | eb645e912dca963645caed932b9adaf184df5f57 (diff) |
sanitize-commit: check for misguided permissions on new files
Sporadically someone commits a source file, image or similar with
execute permission. Let's catch that when it happens; I'm
getting bored of fixing it after the fact.
Change-Id: Ifb8be33f3d0be48466d5613efac09ed6a42fc3e5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'git-hooks')
-rwxr-xr-x | git-hooks/sanitize-commit | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 198ecb6..127f9e2 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -700,9 +700,18 @@ while (<DIFF>) { } next; } - if ($_ eq "new file mode 160000\n" || $_ eq "new file mode 120000\n") { - $is_special = 1; - next; + if (/^new file mode (\d+)$/) { + my $text = $1; + if ($text eq "160000" || $text eq "120000") { + $is_special = 1; + next; + } + if (oct($text) & 0111) { + if ($clike || $qmake || $file =~ /\.(ps|pdf|png|qdoc(cconf)?|json)$/) { + # Should not be executable. + complain("Adding implausibly executable file", "permissions"); + } + } } if (!$is_special && /^index ([\w,]+)\.\.(\w+)(?! 160000)( |$)/) { my ($old_trees, $new_tree) = ($1, $2); |