From 0a3258447685d4437f040174fbb8b7eed8bc62de Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 25 Oct 2018 15:23:30 +0200 Subject: [PATCH] Fix error when inside a bare git repository For example, "git diff" would print "fatal: this operation must be run in a work tree" We could still run git_branch_name in bare repositories in future. --- lib/git/git_is_repo.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/git/git_is_repo.fish b/lib/git/git_is_repo.fish index f72986a..4ce2ff9 100644 --- a/lib/git/git_is_repo.fish +++ b/lib/git/git_is_repo.fish @@ -1,3 +1,7 @@ function git_is_repo -d "Check if directory is a repository" - test -d .git; or command git rev-parse --git-dir >/dev/null 2> /dev/null + test -d .git + or begin + set -l info (command git rev-parse --git-dir --is-bare-repository 2>/dev/null) + and test $info[2] = false + end end