Permalink
Browse files

Gitdir as a function

Getting gitdir is now a function. It prevents the call to git from
outputting an error if we are outside a repository.
  • Loading branch information...
Gabriel Filion
Gabriel Filion committed Feb 14, 2010
1 parent 22c8717 commit b7c53d15527d746f06870762aeb936fff533e181
Showing with 10 additions and 4 deletions.
  1. +10 −4 git-bzr
View
14 git-bzr
@@ -9,10 +9,14 @@ function gitbzr_help_header() {
echo >&2 "git-bzr - Bidirectional operation between Bazaar and git"
}
gitdir=$(git rev-parse --git-dir)
if [ $(uname -s) != "Darwin" ]; then
gitdir=$(readlink -f $gitdir)
fi
function gitbzr_git_directory() {
gitdir=$(git rev-parse --git-dir)
if [ $(uname -s) != "Darwin" ]; then
gitdir=$(readlink -f $gitdir)
fi
echo $gitdir
}
function gitbzr_help_all() {
gitbzr_help_header
@@ -119,6 +123,7 @@ function gitbzr_fetch() {
if [ $# -lt 1 ] ; then
gitbzr_fetch_help
fi
gitdir=$(gitbzr_git_directory)
remote=$1
shift
args=$@
@@ -167,6 +172,7 @@ function gitbzr_push() {
if [ $# -lt 1 ] ; then
gitbzr_push_help
fi
gitdir=$(gitbzr_git_directory)
remote=$1
shift
args=$@

0 comments on commit b7c53d1

Please sign in to comment.