diff options
-rw-r--r-- | nix-utils.sh | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/nix-utils.sh b/nix-utils.sh index 7cd1bb2..39c7b80 100644 --- a/nix-utils.sh +++ b/nix-utils.sh @@ -72,7 +72,7 @@ __git() { # Gets the current branch name or the hash of the current rev if there is no # branch __git_current_branch() { - REV=$(git --git-dir="$1/.git" --work-tree="$1" rev-parse --abbrev-ref HEAD) - ([[ "$REV" -eq "HEAD" ]] && \ - git --git-dir="$1/.git" --work-tree="$1" rev-parse HEAD) || echo "$REV" + branch_name=$(git symbolic-ref -q HEAD) + branch_name=${branch_name##refs/heads/} + ([[ -z "$branch_name" ]] && git rev-parse HEAD) || echo $branch_name } |