{"thread":{"id":"63362","subject":"[PATCH] Fix early wrapping of the command line when using git-prompt.sh","startedAt":"2025-04-28T12:33:55Z","lastAt":"2025-04-28T12:33:55Z","messageCount":1,"participants":["Richard Quadling via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"516890","messageId":"pull.1910.git.1745843632085.gitgitgadget@gmail.com","threadId":"63362","inReplyTo":null,"subject":"[PATCH] Fix early wrapping of the command line when using git-prompt.sh","fromName":"Richard Quadling via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-04-28T12:33:51Z","receivedAt":"2025-04-28T12:33:55Z","isPatch":true,"sender":{"key":"rquadling@gmail.com","avatar":"https://gravatar.com/avatar/4c385f24d4f13c86b9c3e54c61b2532189c1ffb3099a8e63738fd75de90b20ba?d=mp&s=160"},"body":"From: Richard Quadling <RQuadling@GMail.com>\n\nWhen running git-prompt in Bash, the lack of \\001 and \\002 causes\nthe command line to wrap early.\n\nThe issue is the current \\001 and \\002 were not themselves escaped\nand so resulted in binary 0b1 and 0b10 being present, rather than\nthe strings \"\\001\" and \"\\002\".\n\nSigned-off-by: Richard Quadling <RQuadling@GMail.com>\n---\n    Fix early wrapping of the command line when using git-prompt.sh\n    \n    When running git-prompt in Bash, the lack of \\001 and \\002 causes the\n    command line to wrap early.\n    \n    The issue is the current \\001 and \\002 were not themselves escaped and\n    so resulted in binary 0b1 and 0b10 being present, rather than the\n    strings \"\\001\" and \"\\002\".\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1910%2Frquadling%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1910/rquadling/master-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1910\n\n contrib/completion/git-prompt.sh | 2 +-\n t/t9903-bash-prompt.sh           | 8 ++++----\n 2 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 6186c474ba7..4a64aca3eda 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -147,7 +147,7 @@ printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1\n \n # like __git_SOH=$'\\001' etc but works also in shells without $'...'\n eval \"$(printf '\n-\t__git_SOH=\"\\001\" __git_STX=\"\\002\" __git_ESC=\"\\033\"\n+\t__git_SOH=\"\\\\001\" __git_STX=\"\\\\002\" __git_ESC=\"\\033\"\n \t__git_LF=\"\\n\" __git_CRLF=\"\\r\\n\"\n ')\"\n \ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex d667dda654e..fc6fdd36c69 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -13,10 +13,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n . \"$GIT_BUILD_DIR/contrib/completion/git-prompt.sh\"\n \n actual=\"$TRASH_DIRECTORY/actual\"\n-c_red='\\001\\e[31m\\002'\n-c_green='\\001\\e[32m\\002'\n-c_lblue='\\001\\e[1;34m\\002'\n-c_clear='\\001\\e[0m\\002'\n+c_red='\\\\001\\e[31m\\\\002'\n+c_green='\\\\001\\e[32m\\\\002'\n+c_lblue='\\\\001\\e[1;34m\\\\002'\n+c_clear='\\\\001\\e[0m\\\\002'\n \n test_expect_success 'setup for prompt tests' '\n \tgit init otherrepo &&\n\nbase-commit: f65182a99e545d2f2bc22e6c1c2da192133b16a3\n-- \ngitgitgadget\n"}]}