summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-09-17 10:57:46 -0400
committerJesse Luehrs <doy@tozt.net>2023-09-17 10:57:46 -0400
commite727e366d386cb49590c2c65969817f89583656a (patch)
tree29c8caaef2c086235dcca67312deda5ec944c0e9 /bin
parentdf52f6786a48db5045b89bdccb512b2492098e5e (diff)
downloadconf-e727e366d386cb49590c2c65969817f89583656a.tar.gz
conf-e727e366d386cb49590c2c65969817f89583656a.zip
factor out finding the git root
Diffstat (limited to 'bin')
-rwxr-xr-xbin/git/git-root9
1 files changed, 9 insertions, 0 deletions
diff --git a/bin/git/git-root b/bin/git/git-root
new file mode 100755
index 0000000..96fb395
--- /dev/null
+++ b/bin/git/git-root
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -eu
+
+root="$(git rev-parse --show-superproject-working-tree 2>/dev/null)"
+if [ -n "$root" ]; then
+ echo "$root"
+else
+ git rev-parse --show-toplevel
+fi