Fix pre commit hook
This commit is contained in:
parent
ec710177e8
commit
135a4619bc
|
@ -24,6 +24,8 @@ do
|
||||||
git show ":$file" > "$tmpfile"
|
git show ":$file" > "$tmpfile"
|
||||||
# Format it
|
# Format it
|
||||||
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$tmpfile"
|
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$tmpfile"
|
||||||
|
# Format the non-tmp file too, to prevent loops
|
||||||
|
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$file"
|
||||||
# Create a blob object from the formatted file
|
# Create a blob object from the formatted file
|
||||||
hash=`git hash-object -w "$tmpfile"`
|
hash=`git hash-object -w "$tmpfile"`
|
||||||
# Add it back to index
|
# Add it back to index
|
||||||
|
@ -32,6 +34,12 @@ do
|
||||||
rm "$tmpfile"
|
rm "$tmpfile"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# If amend - force succeed
|
||||||
|
IS_AMEND=$(ps -ocommand= -p $PPID | grep -e '--amend');
|
||||||
|
if [ -n "$IS_AMEND" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# If no files left in index after formatting - fail
|
# If no files left in index after formatting - fail
|
||||||
ret=0
|
ret=0
|
||||||
if [ ! "`git diff --cached --name-only`" ]; then
|
if [ ! "`git diff --cached --name-only`" ]; then
|
||||||
|
|
Loading…
Reference in a new issue