From ceb7788c8043021a66fd9e0fe55dfe226f742f70 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Wed, 3 Jan 2018 08:12:39 +0000 Subject: [PATCH] util/gitconfig: Support dash in pre-commit hook On debian systems, /bin/sh is `dash` which has built-in `echo` always interpreting escape sequences such as '\n'. The pre-commit hook uses the built-in for piping diff to checkpatch, interpreting the diff's escape sequences in the process and leading to false negatives and preventing commits despite conformance. Use `printf` instead of `echo` when handling diff content. The bug was introduced in commit ef869305 (util/gitconfig: update pre-commit script). Change-Id: I37edfe7b32721cb63d99299563cb11f26082c9a9 Signed-off-by: Alex Thiessen Reviewed-on: https://review.coreboot.org/23070 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Paul Menzel --- util/gitconfig/pre-commit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/gitconfig/pre-commit b/util/gitconfig/pre-commit index 257f6964bb..1c04bc34e9 100755 --- a/util/gitconfig/pre-commit +++ b/util/gitconfig/pre-commit @@ -2,8 +2,8 @@ %MAKE% lint-stable PATCHDIFF=$(git diff --cached) -if echo "$PATCHDIFF" | grep -q "@@"; then +if printf "%s\n" "$PATCHDIFF" | grep -q "@@"; then echo echo "Running checkpatch" - echo "$PATCHDIFF" | util/lint/checkpatch.pl --no-signoff -q - + printf "%s\n" "$PATCHDIFF" | util/lint/checkpatch.pl --no-signoff -q - fi -- 2.11.4.GIT