diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2014-11-24 19:50:11 +0100 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-11-25 13:21:41 +0000 |
commit | 7f22ce7f6610333f4b40dfad6cde22e352abae6f (patch) | |
tree | 713794744772068bd2103f0d8422e481bbc24fe8 /tools | |
parent | b01ff09eb9e7550aa77e397178007333f94935b4 (diff) |
pre-commit tools: Add arg option to specify the commit id to be checked
If no commit id specify, it is HEAD
Thanks to Michal for the help :-)
Change-Id: Ibf579aed47c7574f9a01d868ae0d55bbe789a8a2
Reviewed-on: https://code.wireshark.org/review/5474
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/pre-commit | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/pre-commit b/tools/pre-commit index aa34474c88..02a52b1a58 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -12,6 +12,13 @@ unset GREP_OPTIONS if [ -z $GIT_DIR ]; then GIT_DIR=".git"; fi +if [ -z $1 ]; then + COMMIT_ID="HEAD" +else + COMMIT_ID=$1 +fi + + # Check for newer versions of the pre-commit script if [ ${GIT_DIR}/hooks/pre-commit -ot ./tools/pre-commit ]; then echo "Pre-commit hook script is outdated, please update!" @@ -19,7 +26,7 @@ fi exit_status=0 -for FILE in `git diff-index --cached --name-status HEAD | grep -v "^D" | cut -f2 | grep "\.[ch]$"` ; do +for FILE in `git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep "\.[ch]$"` ; do #Check if checkhf is good ./tools/checkhf.pl $FILE || exit_status=1 @@ -36,7 +43,7 @@ for FILE in `git diff-index --cached --name-status HEAD | grep -v "^D" | cut -f2 done # If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample) -git diff-index --check --cached HEAD || exit_status=1 +git diff-index --check --cached ${COMMIT_ID} || exit_status=1 exit $exit_status |