public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Richard Quadling via GitGitGadget" <gitgitgadget@gmail•com>
To: git@vger•kernel.org
Cc: Richard Quadling <RQuadling@GMail•com>,
	Richard Quadling <RQuadling@GMail•com>
Subject: [PATCH] Fix early wrapping of the command line when using git-prompt.sh
Date: Mon, 28 Apr 2025 12:33:51 +0000	[thread overview]
Message-ID: <pull.1910.git.1745843632085.gitgitgadget@gmail.com> (raw)

From: Richard Quadling <RQuadling@GMail•com>

When running git-prompt in Bash, the lack of \001 and \002 causes
the command line to wrap early.

The issue is the current \001 and \002 were not themselves escaped
and so resulted in binary 0b1 and 0b10 being present, rather than
the strings "\001" and "\002".

Signed-off-by: Richard Quadling <RQuadling@GMail•com>
---
    Fix early wrapping of the command line when using git-prompt.sh
    
    When running git-prompt in Bash, the lack of \001 and \002 causes the
    command line to wrap early.
    
    The issue is the current \001 and \002 were not themselves escaped and
    so resulted in binary 0b1 and 0b10 being present, rather than the
    strings "\001" and "\002".

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1910%2Frquadling%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1910/rquadling/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1910

 contrib/completion/git-prompt.sh | 2 +-
 t/t9903-bash-prompt.sh           | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 6186c474ba7..4a64aca3eda 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -147,7 +147,7 @@ printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
 
 # like __git_SOH=$'\001' etc but works also in shells without $'...'
 eval "$(printf '
-	__git_SOH="\001" __git_STX="\002" __git_ESC="\033"
+	__git_SOH="\\001" __git_STX="\\002" __git_ESC="\033"
 	__git_LF="\n" __git_CRLF="\r\n"
 ')"
 
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index d667dda654e..fc6fdd36c69 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -13,10 +13,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
 
 actual="$TRASH_DIRECTORY/actual"
-c_red='\001\e[31m\002'
-c_green='\001\e[32m\002'
-c_lblue='\001\e[1;34m\002'
-c_clear='\001\e[0m\002'
+c_red='\\001\e[31m\\002'
+c_green='\\001\e[32m\\002'
+c_lblue='\\001\e[1;34m\\002'
+c_clear='\\001\e[0m\\002'
 
 test_expect_success 'setup for prompt tests' '
 	git init otherrepo &&

base-commit: f65182a99e545d2f2bc22e6c1c2da192133b16a3
-- 
gitgitgadget

             reply	other threads:[~2025-04-28 12:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 12:33 Richard Quadling via GitGitGadget [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-04-28 12:58 [PATCH] Fix early wrapping of the command line when using git-prompt.sh Richard Quadling

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=pull.1910.git.1745843632085.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail$(echo .)com \
    --cc=RQuadling@GMail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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