commit a7931fbfe42ce4ab45e65d9a5ee8105751b4e259
parent 9bf2c8211258588a09a25c9cf322d408676ac878
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 3 Dec 2025 14:59:58 +0100
git-repo: more elegant retrieval of the git directory
git can directly return the absolute path to this directory instead of a
relative path, which then had to be converted to an absolute path.
Furthermore, this final conversion step was buggy.
Diffstat:
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/git-repo b/git-repo
@@ -197,7 +197,8 @@ else
# Retrieve the "git" directory, i.e., the directory where git data is
# stored
- if ! git_dir=$(git rev-parse --git-dir 2>&1); then
+ if ! git_dir=$(git rev-parse --path-format=absolute --git-dir 2>&1)
+ then
>&2 printf '%s: %s\n' "${repo}" "${git_dir}"
die
fi
@@ -212,11 +213,6 @@ else
cd -- "${OLDPWD}"
fi
-# Retrieve absolute path of the git directory
-cd -- "${git_dir}"
-git_dir="$(pwd)"
-cd -- "${OLDPWD}"
-
if [ -n "${group}" ]; then
share "${repo}" "${group}"
fi