From patchwork Tue Jan 9 14:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 19380 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 98436BEFBE for ; Tue, 9 Jan 2024 14:16:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D0E562B30; Tue, 9 Jan 2024 15:16:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1704809790; bh=Sndspa0p6GRdECepK+sYHSfUcsg2baiQTsy8NI3xFgc=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GT64UxtrB2zfvurLgNTEDIzazHpVE/BVFXM2ehLQyNBRCkpSX9Rcp80gU7TYHRdMp ZrNrcSdzKSfYRPN+7JKAC/eFZkNuPYouDfmuxDMNS+hVhaV6tcoUz02DZarUV6wK/g egE/ot31LOAYA7g1S/yTXpP3mhYOinU1tHcKNWmlI2x6vEIgGBEsZgJKWFrFKUByHZ 37SbPa0lGeOw2lxBnf7CoCQGmD4hhi4uniJqH3a3EwE0dIMqWq1/+wuO1Da6zNTsxM 2DyZVdSk04yrVm9OGOJL3svqRFHHrYDz3O1kX/H/yR6AjFJNYMV/+2vSf2XCns5zWz E+8kopF0Q4a6Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECD1361D7B for ; Tue, 9 Jan 2024 15:16:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NOQvE/Ag"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BE614552; Tue, 9 Jan 2024 15:15:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1704809724; bh=Sndspa0p6GRdECepK+sYHSfUcsg2baiQTsy8NI3xFgc=; h=From:To:Cc:Subject:Date:From; b=NOQvE/AgYO2DlEONarayw53A8DzoJOUTrsasthrsELZ+04n+BsYNSNj7sCxC5r1gR JVuS0/wqAmBTFnO9IY0ujlmdXArB4BkZ2riMEYz+pLvy8yf3NrwrxCu5zE22wnuAlY FoOlQUsoeN28L5Tub1aBhjfLfRD1hSIZVbYpmF0o= To: libcamera devel Date: Tue, 9 Jan 2024 14:16:23 +0000 Message-Id: <20240109141623.4131307-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] hooks: pre-push: Disable interpretation of escape sequences X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The pre-push hook validates the commit messages utilising 'echo' to send the captured data from the git commit through grep. Commit messages may occasionally contain strings that could appear to be escape sequences such as doxygen style references to \struct. The '\' 'c' escape sequence can be interpreted to supress all further output [0] which then breaks the processing and string matching. Unfortunatley for us, doxygen's class reference constructed in the same form as \struct can be interpreted as the escape sequence to supress further output. [0] https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins Update the pre-push hook to explicitly disable escape sequence interpretation using the '-E' flag. This is not available on the posix-compliant shell 'dash', so also switch to bash explicitly to prevent potential failures. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- utils/hooks/pre-push | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push index 90ffdf6f1755..9918b2861705 100755 --- a/utils/hooks/pre-push +++ b/utils/hooks/pre-push @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0-or-later @@ -61,7 +61,7 @@ do msg=$(git cat-file commit "$commit") # 1. The commit message shall not contain a local changelog. - if echo "$msg" | grep -q '^--- *$' + if echo -E "$msg" | grep -q '^--- *$' then echo >&2 "Found local changelog in commit $commit" errors=$((errors+1)) @@ -71,7 +71,7 @@ do # corresponding the committer and the author. committer=$(echo "$msg" | grep '^committer ' | head -1 | \ cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev) - if ! echo "$msg" | grep -F -q "Signed-off-by: ${committer}" + if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${committer}" then echo >&2 "Missing committer Signed-off-by in commit $commit" errors=$((errors+1)) @@ -79,21 +79,21 @@ do author=$(echo "$msg" | grep '^author ' | head -1 | \ cut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev) - if ! echo "$msg" | grep -F -q "Signed-off-by: ${author}" + if ! echo -E "$msg" | grep -F -q "Signed-off-by: ${author}" then echo >&2 "Missing author Signed-off-by in commit $commit" errors=$((errors+1)) fi # 3. A Reviewed-by or Acked-by is required. - if ! echo "$msg" | grep -q '^\(Reviewed\|Acked\)-by: ' + if ! echo -E "$msg" | grep -q '^\(Reviewed\|Acked\)-by: ' then echo >&2 "No Reviewed-by or Acked-by in commit $commit" errors=$((errors+1)) fi # 4. The commit message shall not contain a Change-Id. - if echo "$msg" | grep -q '^Change-Id:' + if echo -E "$msg" | grep -q '^Change-Id:' then echo >&2 "Found Change-Id in commit $commit" errors=$((errors+1))