mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Use git rev-parse --git-dir to get the git directory
This commit is contained in:
parent
c2efb5756c
commit
eed0da8643
1 changed files with 2 additions and 13 deletions
|
|
@ -7,21 +7,10 @@
|
|||
|
||||
# Gets the path to the Git directory.
|
||||
function _git-dir {
|
||||
local git_root="$(git-root)"
|
||||
local git_dir_or_file="${git_root}/.git"
|
||||
local git_dir
|
||||
git_dir=("$(git rev-parse --git-dir)"(:A))
|
||||
|
||||
if [[ ! -d "$git_root" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -f "$git_dir_or_file" ]]; then
|
||||
git_dir="${${${$(<"$git_dir_or_file")}[(fr)gitdir:*]}#gitdir: }"
|
||||
else
|
||||
git_dir="$git_dir_or_file"
|
||||
fi
|
||||
|
||||
if [[ -d "$git_dir" ]]; then
|
||||
if [[ -n "$git_dir" ]]; then
|
||||
print "$git_dir"
|
||||
return 0
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue