public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: git@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>
Subject: [PATCH] quiltimport: fix backslash expansion in patch subjects
Date: Sun,  8 Mar 2026 12:55:31 -0400	[thread overview]
Message-ID: <20260308165531.40655-1-sashal@kernel.org> (raw)

echo interprets backslash sequences, so a patch with "\0" in its
subject has that expanded into a NUL byte, which git commit-tree
rejects.

Use printf '%s\n' instead, which doesn't interpret the string.

Also quote $tmp_dir to handle paths with spaces.

Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 git-quiltimport.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index eb34cda409..38302d28c9 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -79,7 +79,7 @@ tmp_info="$tmp_dir/info"
 # Find the initial commit
 commit=$(git rev-parse HEAD)
 
-mkdir $tmp_dir || exit 2
+mkdir "$tmp_dir" || exit 2
 while read patch_name level garbage <&3
 do
 	case "$patch_name" in ''|'#'*) continue;; esac
@@ -101,7 +101,7 @@ do
 		echo "$patch_name doesn't exist. Skipping."
 		continue
 	fi
-	echo $patch_name
+	printf '%s\n' "$patch_name"
 	git mailinfo $MAILINFO_OPT "$tmp_msg" "$tmp_patch" \
 		<"$QUILT_PATCHES/$patch_name" >"$tmp_info" || exit 3
 	test -s "$tmp_patch" || {
@@ -142,14 +142,14 @@ do
 	SUBJECT=$(sed -ne 's/Subject: //p' "$tmp_info")
 	export GIT_AUTHOR_DATE SUBJECT
 	if [ -z "$SUBJECT" ] ; then
-		SUBJECT=$(echo $patch_name | sed -e 's/.patch$//')
+		SUBJECT=$(printf '%s' "$patch_name" | sed -e 's/.patch$//')
 	fi
 
 	if [ -z "$dry_run" ] ; then
 		git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
 		tree=$(git write-tree) &&
-		commit=$( { echo "$SUBJECT"; echo; cat "$tmp_msg"; } | git commit-tree $tree -p $commit) &&
+		commit=$( { printf '%s\n' "$SUBJECT"; echo; cat "$tmp_msg"; } | git commit-tree $tree -p $commit) &&
 		git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
 	fi
 done 3<"$QUILT_SERIES"
-rm -rf $tmp_dir || exit 5
+rm -rf "$tmp_dir" || exit 5

base-commit: 795c338de725e13bd361214c6b768019fc45a2c1
-- 
2.51.0


             reply	other threads:[~2026-03-08 16:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-08 16:55 Sasha Levin [this message]
2026-03-08 20:56 ` [PATCH] quiltimport: fix backslash expansion in patch subjects Ben Knoble
2026-03-08 23:41   ` Sasha Levin
2026-03-09  0:38 ` Junio C Hamano
2026-03-09  1:31   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260308165531.40655-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox