diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-07-11 15:21:11 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-07-11 15:21:11 +0200 |
commit | 1e5a783050dbba2b940a07135fe211b00631a4f4 (patch) | |
tree | 7117bcb90680b8380ef7e35838f0d6aa1dbccc7a | |
parent | 8caba140d1249051101ae2f9dbb505fc5a949118 (diff) | |
parent | af304833d0fdd8d53fb8b96edcf348ab1e57a7f9 (diff) |
Merge pull request #54 from matthiasbeyer/fix-#36
Rewrite __git_current_branch()
-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 } |