mirror of
https://github.com/frej/fast-export.git
synced 2026-01-15 02:32:05 +01:00
Fix broken support for bare repositories
The change in 6cf9397bd6 broke support for
bare repositories. In a bare repo git rev-parse --show-toplevel would
return an empty string and cwd would then be changed to the user's home
directory. In the home directory git rev-parse --git-dir would either
fail or return an unrelated repo.
Problem reported by Ralf Rösch.
This commit is contained in:
@@ -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
|
||||
|
||||
10
hg-reset.sh
10
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
|
||||
|
||||
Reference in New Issue
Block a user