From 0116dc5984685aa0e25f9ef84c688dde790dfd0e Mon Sep 17 00:00:00 2001 From: ClaXXX <58471398+ClaXXX@users.noreply.github.com> Date: Thu, 2 May 2024 19:37:12 +0200 Subject: [PATCH] Fix the acidhub prompt for a commitless repository (#10462) Deletes the error message generated by git when comparing indexes for a commitless repository and print '-' as the branch name --- share/tools/web_config/sample_prompts/acidhub.fish | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/share/tools/web_config/sample_prompts/acidhub.fish b/share/tools/web_config/sample_prompts/acidhub.fish index 0adb527d5..17ccb664d 100644 --- a/share/tools/web_config/sample_prompts/acidhub.fish +++ b/share/tools/web_config/sample_prompts/acidhub.fish @@ -5,10 +5,9 @@ function fish_prompt -d "Write out the prompt" set -l laststatus $status set -l git_info - if set -l git_branch (command git symbolic-ref HEAD 2>/dev/null | string replace refs/heads/ '') - set git_branch (set_color -o blue)"$git_branch" + if set -l git_branch (command git branch --format=%\(refname:lstrip=2\) 2> /dev/null) set -l git_status - if not command git diff-index --quiet HEAD -- + if test -n "$git_branch"; and not command git diff-index --quiet HEAD -- if set -l count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null) echo $count | read -l ahead behind if test "$ahead" -gt 0 @@ -36,8 +35,11 @@ function fish_prompt -d "Write out the prompt" end else set git_status (set_color green): + if test -z "$git_branch" + set git_branch "-" + end end - set git_info "(git$git_status$git_branch"(set_color white)")" + set git_info "(git$git_status"(set_color -o blue)"$git_branch"(set_color white)")" end # Disable PWD shortening by default.