]> gitweb.fluxo.info Git - utils-git.git/commitdiff
Fix: sup, rsup: git repository check
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 3 Aug 2024 01:20:40 +0000 (22:20 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 3 Aug 2024 01:20:40 +0000 (22:20 -0300)
rsup
sup

diff --git a/rsup b/rsup
index c90a8a3e3cd32a9c604db310a1dd029fe0316957..59d95d03beef71921f44fad65fd53ad14bba2fc3 100755 (executable)
--- a/rsup
+++ b/rsup
@@ -57,7 +57,11 @@ function upward_commit {
 }
 
 # Check if it is a git repository
-if [ ! -d ".git" ]; then
+# Thanks https://stackoverflow.com/questions/4917871/does-git-return-specific-return-error-codes#comment124785102_19441790
+#git status &> /dev/null
+#if [ ! -d ".git" ]; then
+#if [ "$?" == "128" ]; then
+if [ "`git rev-parse --is-inside-work-tree &> /dev/null`" == "true" ]; then
   echo "$BASENAME: not a git repository"
   exit 1
 fi
diff --git a/sup b/sup
index 35644181245b70d9fe8191817cc061ddcc90b0db..842ad5a17d0c65ff5c84cd89993c6bc84512cea1 100755 (executable)
--- a/sup
+++ b/sup
@@ -39,9 +39,9 @@ GIT="hit"
 #  done
 #}
 
-# Check if it is a git repository
+# Check if it is a git repository, and wheter we're in the top of it
 if [ ! -d ".git" ]; then
-  echo "$BASENAME: not a git repository"
+  echo "$BASENAME: not a git repository, or not in the top-level of that repository"
   exit 1
 fi