From 9aadfdd650bc32150c9800b73fb3e5ac83fc5a72 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 11 Jun 2020 09:57:58 +0200 Subject: [PATCH] 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. --- contrib/prepare-commit-msg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/prepare-commit-msg b/contrib/prepare-commit-msg index 24f0783..57bb917 100755 --- a/contrib/prepare-commit-msg +++ b/contrib/prepare-commit-msg @@ -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" -- 2.7.4