Skip to content

Commit 293623e

Browse files
author
Junio C Hamano
committed
git-commit: use printf '%s\n' instead of echo on user-supplied strings
This fixes the same issue git-am had, which was fixed by Jeff King in the previous commit. Cleverly enough, this commit's log message is a good test case at the same time. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 4b7cc26 commit 293623e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

git-commit.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ t,)
376376
rm -f "$TMP_INDEX"
377377
fi || exit
378378

379-
echo "$commit_only" |
379+
printf '%s\n' "$commit_only" |
380380
GIT_INDEX_FILE="$TMP_INDEX" \
381381
git-update-index --add --remove --stdin &&
382382

383383
save_index &&
384-
echo "$commit_only" |
384+
printf '%s\n' "$commit_only" |
385385
(
386386
GIT_INDEX_FILE="$NEXT_INDEX"
387387
export GIT_INDEX_FILE
@@ -432,7 +432,7 @@ fi
432432

433433
if test "$log_message" != ''
434434
then
435-
echo "$log_message"
435+
printf '%s\n' "$log_message"
436436
elif test "$logfile" != ""
437437
then
438438
if test "$logfile" = -
@@ -475,7 +475,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
475475
echo "#"
476476
echo "# It looks like you may be committing a MERGE."
477477
echo "# If this is not correct, please remove the file"
478-
echo "# $GIT_DIR/MERGE_HEAD"
478+
printf '%s\n' "# $GIT_DIR/MERGE_HEAD"
479479
echo "# and try again"
480480
echo "#"
481481
fi >>"$GIT_DIR"/COMMIT_EDITMSG

0 commit comments

Comments
 (0)