contrib: Avoid redundant 'git diff' in prepare-commit-msg hook
authorJonathan Wakely <jwakely@redhat.com>
Thu, 11 Jun 2020 07:57:58 +0000 (09:57 +0200)
committerMartin Liska <mliska@suse.cz>
Thu, 11 Jun 2020 07:57:58 +0000 (09:57 +0200)
contrib/ChangeLog:

* prepare-commit-msg: Use 'tee' to save the diff to a file
instead of running 'git diff' twice.

contrib/prepare-commit-msg

index 24f0783aae24e59b7954dac3693ae598a3180db7..57bb91747f68f96d9dcc597ef7ec6c710c985ce4 100755 (executable)
@@ -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"