diff --git a/hg-fast-export.sh b/hg-fast-export.sh index f3f58f6..d0dd506 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -49,9 +49,15 @@ case "$1" in exit 0 esac -cd $(git rev-parse --show-toplevel) \ +IS_BARE=$(git rev-parse --is-bare-repository) \ || (echo "Could not find git repo" ; exit 1) -GIT_DIR=$(git rev-parse --git-dir) || exit 1 +if test "z$IS_BARE" != ztrue; then + # This is not a bare repo, cd to the toplevel + TOPLEVEL=$(git rev-parse --show-toplevel) \ + || (echo "Could not find git repo toplevel" ; exit 1) + cd $TOPLEVEL || exit 1 +fi +GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1) while case "$#" in 0) break ;; esac do diff --git a/hg-reset.sh b/hg-reset.sh index d7fbff7..453dbab 100755 --- a/hg-reset.sh +++ b/hg-reset.sh @@ -24,9 +24,15 @@ Options: -r Mercurial repository to use " -cd $(git rev-parse --show-toplevel) \ +IS_BARE=$(git rev-parse --is-bare-repository) \ || (echo "Could not find git repo" ; exit 1) -GIT_DIR=$(git rev-parse --git-dir) || exit 1 +if test "z$IS_BARE" != ztrue; then + # This is not a bare repo, cd to the toplevel + TOPLEVEL=$(git rev-parse --show-toplevel) \ + || (echo "Could not find git repo toplevel" ; exit 1) + cd $TOPLEVEL || exit 1 +fi +GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1) while case "$#" in 0) break ;; esac do