Update pre-commit hook
This commit is contained in:
parent
f5d6a55b97
commit
ac34813571
|
@ -17,16 +17,19 @@ fi
|
|||
for file in `git diff --cached --name-only --diff-filter=ACMR | grep $exts`
|
||||
do
|
||||
echo "Formatting $file"
|
||||
# get tmpfile
|
||||
tmpfile="${file//.cpp/.tmp.cpp}"
|
||||
tmpfile="${file//.h/.tmp.h}"
|
||||
# Get the file from index
|
||||
git show ":$file" > "$file.tmp"
|
||||
git show ":$file" > "$tmpfile"
|
||||
# Format it
|
||||
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$file.tmp"
|
||||
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$tmpfile"
|
||||
# Create a blob object from the formatted file
|
||||
hash=`git hash-object -w "$file.tmp"`
|
||||
hash=`git hash-object -w "$tmpfile"`
|
||||
# Add it back to index
|
||||
git update-index --add --cacheinfo 100644 "$hash" "$file"
|
||||
# Remove the tmp file
|
||||
rm "$file.tmp"
|
||||
rm "$tmpfile"
|
||||
done
|
||||
|
||||
# If no files left in index after formatting - fail
|
||||
|
|
Loading…
Reference in a new issue