aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2024-06-06 21:45:30 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-06-06 21:45:30 +0000
commita2c88e0d47acb1a33016cbb7a821465fa1e357a6 (patch)
tree7983538f05213c8fd3fbf3ec1a3f3e3f46aadc5e
parentdb42bd1f71b1a29b392aacbd5b7aaca4c8d7e85d (diff)
git-arc: Use a helper function to fetch boolean config variables
Requested by: markj Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D45104
-rw-r--r--tools/tools/git/git-arc.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
index e8da1f1ed32a..e9398a60d2f7 100644
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -148,6 +148,16 @@ __EOF__
}
#
+# Fetch the value of a boolean config variable ($1) and return true
+# (0) if the variable is true. The default value to use if the
+# variable is not set is passed in $2.
+#
+get_bool_config()
+{
+ test "$(git config --bool --get $1 2>/dev/null || echo $2)" != "false"
+}
+
+#
# Filter the output of call-conduit to remove the warnings that are generated
# for some installations where openssl module is mysteriously installed twice so
# a warning is generated. It's likely a local config error, but we should work
@@ -378,7 +388,7 @@ gitarc__create()
list=
prev=""
- if [ "$(git config --bool --get arc.list 2>/dev/null || echo false)" != "false" ]; then
+ if get_bool_config arc.list false; then
list=1
fi
doprompt=1
@@ -672,7 +682,7 @@ gitarc__update()
local commit commits diff doprompt have_msg list o msg
list=
- if [ "$(git config --bool --get arc.list 2>/dev/null || echo false)" != "false" ]; then
+ if get_bool_config arc.list false; then
list=1
fi
doprompt=1
@@ -727,7 +737,7 @@ gitarc__update()
set -e
ASSUME_YES=
-if [ "$(git config --bool --get arc.assume-yes 2>/dev/null || echo false)" != "false" ]; then
+if get_bool_config arc.assume-yes false; then
ASSUME_YES=1
fi
@@ -801,7 +811,7 @@ list|patch)
;;
esac
-if [ "$(git config --bool --get arc.browse 2>/dev/null || echo false)" != "false" ]; then
+if get_bool_config arc.browse false; then
BROWSE=--browse
fi