git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit 1a37fb2c0454107f6962c06adaa48aad565ee9af
parent 7e6d4172a68c3e02af6772be46933cdc6215ac4d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  2 Oct 2024 12:08:45 +0200

Check that git-wad is not running in a .git dir

Some versions of git return an error when "git rev-parse" is executed in
a git directory, but others do not. Letting git handle the error when it
queries the working directory is therefore not sufficient: no error
could be reported when git-wad should not be executed from the current
directory. Hence this commit, which explicitly checks the current
directory before executing the git-wad command.

Diffstat:
Mgit-wad | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/git-wad b/git-wad @@ -23,6 +23,13 @@ die() exit "${1:-1}" # return status code (default is 1) } +# Check that git-wad does not run from a .git directory +is_inside_git_dir="$(git rev-parse --is-inside-git-dir)" +if [ "${is_inside_git_dir}" = "true" ]; then + >&2 printf 'git-wad must be run in a work tree\n' + die +fi + # shellcheck disable=SC2310 working_tree="$(git rev-parse --show-toplevel)" || die "$?" git_wad_tmpdir="$(mktemp -d "${TMPDIR:-/tmp}/git_wad_XXXXXX")" || die "$?"