Enforce git commands being run inside git folder

This commit is contained in:
Felix Buehler 2025-07-31 23:48:39 +02:00
parent 72ceb16f5f
commit ad24ebe4a2

View file

@ -1,5 +1,8 @@
#!/bin/sh #!/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 # save as i.e.: git-authors and set the executable flag
git ls-tree -r -z --name-only HEAD -- "${1}" \ git ls-tree -r -z --name-only HEAD -- "${1}" \
| xargs -0 -n1 git blame --line-porcelain HEAD \ | xargs -0 -n1 git blame --line-porcelain HEAD \
@ -7,4 +10,3 @@ git ls-tree -r -z --name-only HEAD -- "${1}" \
| sort \ | sort \
| uniq -c \ | uniq -c \
| sort -nr | sort -nr