contrib: Avoid redundant 'git diff' in prepare-commit-msg hook

contrib/ChangeLog:

	* prepare-commit-msg: Use 'tee' to save the diff to a file
	instead of running 'git diff' twice.
This commit is contained in:
Jonathan Wakely 2020-06-11 09:57:58 +02:00 committed by Martin Liska
parent 656e363bcc
commit 9aadfdd650
No known key found for this signature in database
GPG Key ID: 4DC182DC0FA73785
1 changed files with 4 additions and 2 deletions

View File

@ -59,7 +59,9 @@ fi
# Save diff to a file if requested.
if ! [ -z "$GCC_GIT_DIFF_FILE" ]; then
git $cmd > "$GCC_GIT_DIFF_FILE";
tee="tee $GCC_GIT_DIFF_FILE"
else
tee="cat"
fi
git $cmd | git gcc-mklog -c "$COMMIT_MSG_FILE"
git $cmd | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"