diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2009-06-03 10:36:56 +0200 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2009-06-03 10:38:31 +0200 |
commit | 0016ab05ecd2959c3a69d42d34ada53c13a18d96 (patch) | |
tree | 41308225697f7449ae3ff63f574892ebd7efa09e /01_Functions.zsh | |
parent | 60f2817d429672780b416f6732e3e1ea76cafd81 (diff) |
[Funcs/git] Get branch on an initialized repo with symlink HEAD
Diffstat (limited to '01_Functions.zsh')
-rw-r--r-- | 01_Functions.zsh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh index ad4c10a..35cc361 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -106,7 +106,12 @@ get_git_branch () fi else # Initial commit - my_git_branch="$(basename $GIT_DIR/$(cat $GIT_DIR/HEAD | sed 's/^\([0-9a-f]\{2\}\)\([0-9a-f]\{38\}\)$/objects\/\1\/\2/;s/^ref: //'))" + if [ -L $GIT_DIR/HEAD -a ! -f $GIT_DIR/HEAD ] + then + my_git_branch="$(basename $GIT_DIR/$(stat --printf="%N\n" $GIT_DIR/HEAD | tr '`' "'" | cut -d\' -f4))" + else + my_git_branch="$(basename $GIT_DIR/$(cat $GIT_DIR/HEAD | sed 's/^\([0-9a-f]\{2\}\)\([0-9a-f]\{38\}\)$/objects\/\1\/\2/;s/^ref: //'))" + fi fi echo $my_git_branch |