From: Mark Zhuang <[email protected]>

The previous commit added --default-prefix to handle non-default git
prefix configurations, but this option is not available in older git
versions. This patch adds a compatibility check.

contrib/ChangeLog:

        * prepare-commit-msg: check --default-prefix
---
 contrib/prepare-commit-msg | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/contrib/prepare-commit-msg b/contrib/prepare-commit-msg
index 75d102559c7..9387b332b34 100755
--- a/contrib/prepare-commit-msg
+++ b/contrib/prepare-commit-msg
@@ -78,4 +78,9 @@ else
     tee="cat"
 fi
 
-git $cmd --default-prefix | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"
+# Use --default-prefix if supported
+if git diff --help | grep -q "\-\-default-prefix" 2>/dev/null; then
+    cmd="$cmd --default-prefix"
+fi
+
+git $cmd | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"
-- 
2.34.1

Reply via email to