[{"id":28424,"web_url":"https://patchwork.libcamera.org/comment/28424/","msgid":"<20240109142550.GC17461@pendragon.ideasonboard.com>","date":"2024-01-09T14:25:50","subject":"Re: [libcamera-devel] [PATCH] hooks: pre-push: Disable\n\tinterpretation of escape sequences","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Tue, Jan 09, 2024 at 02:16:23PM +0000, Kieran Bingham via libcamera-devel wrote:\n> The pre-push hook validates the commit messages utilising 'echo' to send\n> the captured data from the git commit through grep.\n> \n> Commit messages may occasionally contain strings that could appear to be\n> escape sequences such as doxygen style references to \\struct.\n> \n> The '\\' 'c' escape sequence can be interpreted to supress all further\n> output [0] which then breaks the processing and string matching.\n> \n> Unfortunatley for us, doxygen's class reference constructed in the same\n> form as \\struct can be interpreted as the escape sequence to supress\n> further output.\n> \n> [0] https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins\n> \n> Update the pre-push hook to explicitly disable escape sequence\n> interpretation using the '-E' flag. This is not available on the\n> posix-compliant shell 'dash', so also switch to bash explicitly to\n> prevent potential failures.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  utils/hooks/pre-push | 12 ++++++------\n>  1 file changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push\n> index 90ffdf6f1755..9918b2861705 100755\n> --- a/utils/hooks/pre-push\n> +++ b/utils/hooks/pre-push\n> @@ -1,4 +1,4 @@\n> -#!/bin/sh\n> +#!/bin/bash\n>  \n>  # SPDX-License-Identifier: GPL-2.0-or-later\n>  \n> @@ -61,7 +61,7 @@ do\n>  \t\tmsg=$(git cat-file commit \"$commit\")\n>  \n>  \t\t# 1. The commit message shall not contain a local changelog.\n> -\t\tif echo \"$msg\" | grep -q '^--- *$'\n> +\t\tif echo -E \"$msg\" | grep -q '^--- *$'\n>  \t\tthen\n>  \t\t\techo >&2 \"Found local changelog in commit $commit\"\n>  \t\t\terrors=$((errors+1))\n> @@ -71,7 +71,7 @@ do\n>  \t\t# corresponding the committer and the author.\n>  \t\tcommitter=$(echo \"$msg\" | grep '^committer ' | head -1 | \\\n>  \t\t\t\tcut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)\n> -\t\tif ! echo \"$msg\" | grep -F -q \"Signed-off-by: ${committer}\"\n> +\t\tif ! echo -E \"$msg\" | grep -F -q \"Signed-off-by: ${committer}\"\n>  \t\tthen\n>  \t\t\techo >&2 \"Missing committer Signed-off-by in commit $commit\"\n>  \t\t\terrors=$((errors+1))\n> @@ -79,21 +79,21 @@ do\n>  \n>  \t\tauthor=$(echo \"$msg\" | grep '^author ' | head -1 | \\\n>  \t\t\t\tcut -d ' ' -f 2- | rev | cut -d ' ' -f 3- | rev)\n> -\t\tif ! echo \"$msg\" | grep -F -q \"Signed-off-by: ${author}\"\n> +\t\tif ! echo -E \"$msg\" | grep -F -q \"Signed-off-by: ${author}\"\n>  \t\tthen\n>  \t\t\techo >&2 \"Missing author Signed-off-by in commit $commit\"\n>  \t\t\terrors=$((errors+1))\n>  \t\tfi\n>  \n>  \t\t# 3. A Reviewed-by or Acked-by is required.\n> -\t\tif ! echo \"$msg\" | grep -q '^\\(Reviewed\\|Acked\\)-by: '\n> +\t\tif ! echo -E \"$msg\" | grep -q '^\\(Reviewed\\|Acked\\)-by: '\n>  \t\tthen\n>  \t\t\techo >&2 \"No Reviewed-by or Acked-by in commit $commit\"\n>  \t\t\terrors=$((errors+1))\n>  \t\tfi\n>  \n>  \t\t# 4. The commit message shall not contain a Change-Id.\n> -\t\tif echo \"$msg\" | grep -q '^Change-Id:'\n> +\t\tif echo -E \"$msg\" | grep -q '^Change-Id:'\n>  \t\tthen\n>  \t\t\techo >&2 \"Found Change-Id in commit $commit\"\n>  \t\t\terrors=$((errors+1))","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EAAA1C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Jan 2024 14:25:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DD3262B32;\n\tTue,  9 Jan 2024 15:25:44 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B6F2262B30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Jan 2024 15:25:41 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 61EEA552;\n\tTue,  9 Jan 2024 15:24:37 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1704810344;\n\tbh=SCwBWZWVYncL1g3mdxCqmKOgjZ1Pal5H8CaSdhP+ELI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=SPvzN9UMixV5JJSfxU28PdHeBXSdlaS+cyOnSElKMxNoi+dX1nzgH/921Gcv4uTM2\n\tt1Y1fVQFLygmo5hy671CybOS5gT9I/H8isqujhXuCqaCXSQkR3eVbMC/jTzs8r4Dez\n\t+gEeuCIir0jPixx9m+DtFnoY8++5A7uKc4s1CZejlnccG/xtBdxp6ifFHelgdl//AM\n\tRCR+F+IzBT2c35GftdqY3uU6nlcGvkH3ADWX81OY8XjGxGmgPhK8gGdGVIz+CZFXmD\n\tKchut+rJuNTp7HlPvpGPkkR+bgcESJ4w700QNQhYu0R7xnHh4UTHqmVN7D6Bgu2OYr\n\teb+Y0dhAD19UQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1704810277;\n\tbh=SCwBWZWVYncL1g3mdxCqmKOgjZ1Pal5H8CaSdhP+ELI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=o6B7EymivyI4qWQYEbL7dLMvC+v3dguO7bplgnSZ4yle17TVLvCcR4oDeHlWPNXpi\n\tYoYhXEoJHnm2JEp2n80E1Xg1lUd3d8RMKO5KupTk206WqdmyH4hG+vZzsM2XBQ6b9s\n\tzAA7V+x/Nvr+lQ/725/7SnkrXEnoeaEO1iNPn44I="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"o6B7Eymi\"; dkim-atps=neutral","Date":"Tue, 9 Jan 2024 16:25:50 +0200","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20240109142550.GC17461@pendragon.ideasonboard.com>","References":"<20240109141623.4131307-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240109141623.4131307-1-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] hooks: pre-push: Disable\n\tinterpretation of escape sequences","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]