Skip to content

Commit ed95db9

Browse files
committed
Include copied and renamed files in the set of changed files
1 parent dbf2000 commit ed95db9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tools/git/hooks/pre-commit

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ check_filenames() {
7676
against='HEAD'
7777
fi
7878
# We exploit the fact that the printable range starts with the space character and ends with the tilde. Note that the use of brackets around a `tr` range is okay here, (for portability to Solaris 10's /usr/bin/tr, it's even required), since the square bracket bytes happen to fall in the designated range.
79-
num_files=$(git diff --cached --name-only --diff-filter=A -z "${against}" | LC_ALL=C tr -d '[ -~]\0' | wc -c)
79+
num_files=$(git diff --cached --name-only --diff-filter=ACR -z "${against}" | LC_ALL=C tr -d '[ -~]\0' | wc -c)
8080

8181
if [[ "${num_files}" -ne 0 ]]; then
8282
echo 'Error: Attempting to add a non-ASCII filename. Non-ASCII filenames limit cross-platform portability. Please rename offending files before committing.' >&2
@@ -90,8 +90,8 @@ run_lint() {
9090
local changed_files
9191
local files
9292

93-
# Get the set of changed files (added and modified):
94-
changed_files=$(git diff --name-only --cached --diff-filter AM)
93+
# Get the set of changed files (added, copied, modified, and renamed):
94+
changed_files=$(git diff --name-only --cached --diff-filter ACMR)
9595

9696
# Lint filenames:
9797
echo "${changed_files}" | "${lint_filenames}"

tools/git/hooks/pre-push

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ main() {
109109
on_error 1
110110
fi
111111

112-
# Get the set of changed files (added and modified):
113-
changed_files=$(git diff --name-only --cached --diff-filter AM "${remote}/${GIT_CURRENT_BRANCH}" | sed -e "s#^#${root}\\/#")
112+
# Get the set of changed files (added, copied, modified, and renamed):
113+
changed_files=$(git diff --name-only --cached --diff-filter ACMR "${remote}/${GIT_CURRENT_BRANCH}" | sed -e "s#^#${root}\\/#")
114114

115115
# Run JavaScript example files:
116116
files=$(echo "${changed_files}" | grep '/examples/.*\.js$' | grep -v '/examples/fixtures/.*\.js$' | tr '\n' ' ')

0 commit comments

Comments
 (0)