2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Check binary files that might be wrongly committed.
18 # Usage: checkbinaryfiles.sh from to
20 from
=${1:-origin/master}
25 cd `git rev-parse --show-toplevel`
29 echo "checkbinaryfiles $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)"
30 git
diff --name
-only
--diff-filter
=d
--no
-renames
$from..
$to -z
> checkbinaryfiles_files.out
31 if test \
! -s checkbinaryfiles_files.out
; then
32 echo "No committed files"
35 # Identify binary files with the presence of a null byte or a control char (except \n \r \t)
36 xargs -0 grep -Pal
'[\x00-\x08\x0B-\x0C\x0E-\x1F]' < checkbinaryfiles_files.out
> checkbinaryfiles_application.out
2> /dev
/null
37 if test -s checkbinaryfiles_application.out
; then
38 echo "These files type need a manual check:"
40 cat checkbinaryfiles_application.out
42 echo "Please double check that they are not wrongly committed files or that unexpected strange control characters are not included in them."
45 echo "All committed files seem good"