From ad24ebe4a21ba3c1fb74bd364550a497a7f89542 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Thu, 31 Jul 2025 23:48:39 +0200 Subject: [PATCH] Enforce git commands being run inside git folder --- bin/git-authors.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/git-authors.sh b/bin/git-authors.sh index 3383558..709dacb 100755 --- a/bin/git-authors.sh +++ b/bin/git-authors.sh @@ -1,5 +1,8 @@ #!/bin/sh +# Enforce being in a git repository +git rev-parse --is-inside-work-tree >/dev/null || exit $? + # save as i.e.: git-authors and set the executable flag git ls-tree -r -z --name-only HEAD -- "${1}" \ | xargs -0 -n1 git blame --line-porcelain HEAD \ @@ -7,4 +10,3 @@ git ls-tree -r -z --name-only HEAD -- "${1}" \ | sort \ | uniq -c \ | sort -nr -