From 66537fbcde3c6390b99f6ce8cd89825aa5c90093 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Tue, 10 Oct 2023 16:25:34 +0100 Subject: [PATCH] Fix branch detection. --- .bashrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bashrc b/.bashrc index 7e792c5..adfd6ab 100644 --- a/.bashrc +++ b/.bashrc @@ -52,9 +52,9 @@ __prompt_git_status() { fi } - # Add the branch if there have been commits. - if [[ -e "${GIT_REPO_INFO[1]}/refs/heads/master" ]]; then - BRANCH="$(git describe --contains --all HEAD)" + # Add the branch or a no commits marker. + BRANCH="$(git describe --contains --all HEAD 2>/dev/null)" + if [[ -n "$BRANCH" ]]; then GIT_PROMPT+="$BRANCH" else GIT_PROMPT+="!NO COMMITS!"