From f4c19f9d51cd05cb465aba57c336ebe8334013fc Mon Sep 17 00:00:00 2001 From: Amand Tihon Date: Mon, 24 Jan 2011 10:36:04 +0100 Subject: [PATCH] Git prompt: Fix missing subdirectory When under .git, the prompt now shows the correct path to current directory. --- S60_git | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/S60_git b/S60_git index 54e61d4..7a9ba7a 100644 --- a/S60_git +++ b/S60_git @@ -95,10 +95,15 @@ git_parse() { git_dir=$(git rev-parse --git-dir 2> /dev/null) || return - base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'} + if [[ "$(git rev-parse --is-bare-repository)" == "true" ]]; then + base_dir=${$(readlink -f "$git_dir")/$HOME/'~'} + sub_dir=${$(pwd)#$(readlink -f "$git_dir")} + else + base_dir=${$(readlink -f "$git_dir/..")/$HOME/'~'} + sub_dir=${$(pwd)#$(readlink -f "$git_dir/..")} + fi - sub_dir=$(git rev-parse --show-prefix) - sub_dir=${sub_dir%/} + sub_dir=${sub_dir#/} ref=$(git symbolic-ref HEAD 2> /dev/null) || return action="" -- 2.39.5