git: 6a720fb95a1b - main - git-arc: Fix handling of review title containing double quotes

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 04 Oct 2022 17:06:20 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=6a720fb95a1bc39c6417fa6200789edfe99d5256

commit 6a720fb95a1bc39c6417fa6200789edfe99d5256
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-10-04 16:59:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-10-04 17:05:54 +0000

    git-arc: Fix handling of review title containing double quotes
---
 tools/tools/git/git-arc.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
index 22a13aa307bd..a9faed2ea876 100644
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -193,7 +193,7 @@ title2diff()
 {
     local title
 
-    title=$1
+    title=$(echo $1 | sed 's/"/\\"/g')
     # arc list output always includes ANSI escape sequences, strip them.
     arc list | sed 's/\x1b\[[0-9;]*m//g' | \
         awk -F': ' '{
@@ -422,7 +422,8 @@ gitarc__list()
         # differently and keep the entire status.
         title=$(git show -s --format=%s "$commit")
         diff=$(echo "$openrevs" | \
-            awk -F'D[1-9][0-9]*:\.\\[m ' '{if ($2 == "'"$title"'") print $0}')
+            awk -F'D[1-9][0-9]*:\.\\[m ' \
+                '{if ($2 == "'"$(echo $title | sed 's/"/\\"/g')"'") print $0}')
         if [ -z "$diff" ]; then
             echo "No Review      : $title"
         elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then