[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1e1716f 5/7: Assert rather than assume
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1e1716f 5/7: Assert rather than assume |
Date: |
Thu, 16 Nov 2017 11:09:55 -0500 (EST) |
branch: master
commit 1e1716ff2a40df817ab2390535c43f6509058583
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Assert rather than assume
Added an enforced precondition that $PWD is a git toplevel directory.
Renumbered exit codes so that each is unique.
---
check_git_setup.sh | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/check_git_setup.sh b/check_git_setup.sh
index 3d151dd..2488292 100755
--- a/check_git_setup.sh
+++ b/check_git_setup.sh
@@ -21,10 +21,14 @@
# email: <address@hidden>
# snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-# Do this in the directory where this script resides, which is
-# deliberately the "toplevel" directory.
+# Navigate to the directory where this script resides, and make sure
+# it's a git "toplevel" directory.
cd $(dirname $(readlink -f $0))
+toplevel=$(git rev-parse --show-toplevel)
+printf "'%s' is current directory\n" $PWD
+printf "'%s' is git toplevel directory\n" $toplevel
+[ "$PWD" = "$toplevel" ] || { printf "fail: PWD is not toplevel\n"; exit 1; }
# For msw (cygwin) only, make sure 'core.filemode' is "false". See:
# https://lists.nongnu.org/archive/html/lmi/2017-11/msg00018.html
@@ -66,11 +70,11 @@ case "$(readlink -f .git/hooks)" in
;;
("$PWD/.git/hooks")
printf "attempted hooks/ change failed\n"
- exit 1
+ exit 3
;;
(*)
printf "unanticipated error\n"
- exit 2
+ exit 4
;;
esac
- [lmi-commits] [lmi] master updated (2a7f972 -> c8de75e), Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master 0b4d84b 2/7: Prefer $PWD to $(pwd), Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master bf52d55 6/7: Require a valid pre-commit hook to exist, Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master 68cc423 4/7: Regularize readlink options, Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master f92ba83 3/7: Allow backup of old .git/hooks to fail, Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master 1e1716f 5/7: Assert rather than assume,
Greg Chicares <=
- [lmi-commits] [lmi] master 030f1c5 1/7: Fix incorrect command order, Greg Chicares, 2017/11/16
- [lmi-commits] [lmi] master c8de75e 7/7: Show symlink in a few of its many guises, Greg Chicares, 2017/11/16