diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2015-01-12 10:17:31 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-01-12 13:20:16 +0100 |
commit | 0d7f50bdc6f63ed1de9558e5242d39f78a95d608 (patch) | |
tree | 6ba09868f5f090d53c5c1224521793c83e6509eb /git-hooks | |
parent | e4052fd97851ecdff45b26436b050922d8c6cf6e (diff) |
re-implement executable detection without external 'file' command
... for windows-compatibility.
as a side effect, it's also faster.
Change-Id: I7b3e83abd832bdf3f35acf9894c101ee7402e698
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'git-hooks')
-rwxr-xr-x | git-hooks/sanitize-commit | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 9b110e6..9d805fe 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -441,8 +441,9 @@ sub formatSize($) sub isExe($) { my $sha = shift; - my $type = `git cat-file -p $sha | file -b -`; - return $type =~ /^(ELF|PE32) /; + open(my $hndl, "git cat-file -p $sha |") or return 0; + read($hndl, my $hdr, 4) or return 0; + return $hdr =~ /^(\x7FELF|MZ)/; } my $no_copyright = 0; |