From 0016ab05ecd2959c3a69d42d34ada53c13a18d96 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 3 Jun 2009 10:36:56 +0200 Subject: [Funcs/git] Get branch on an initialized repo with symlink HEAD --- 01_Functions.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to '01_Functions.zsh') 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 -- cgit v1.2.3 From 7e6dee86f24c41338c9294dbd5f83ce8155b6d96 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 3 Jun 2009 14:13:51 +0200 Subject: [Funcs/git] shows added files in git branch --- 01_Functions.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to '01_Functions.zsh') diff --git a/01_Functions.zsh b/01_Functions.zsh index 35cc361..3b7a517 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -114,6 +114,11 @@ get_git_branch () fi fi + if [ "$(git-status 2>&- | grep "new file" | head -n1)" != "" ] ; then + # ADDED FILES + my_git_branch=$my_git_branch" (+)" + fi + echo $my_git_branch } @@ -136,7 +141,7 @@ get_git_status () if [ "$(git-diff --cached 2>&- | grep '^diff ' | head -n1 )" != "" ] ; then cached="yes" fi - if [ "$(git-ls-files -m 2>&-)" != "" ] ; then + if [ "$(git-ls-files -m 2>&- | head -n1)" != "" ] ; then not_up_to_date="yes" fi -- cgit v1.2.3