git: a2c88e0d47ac - main - git-arc: Use a helper function to fetch boolean config variables
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 06 Jun 2024 21:45:42 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a2c88e0d47acb1a33016cbb7a821465fa1e357a6 commit a2c88e0d47acb1a33016cbb7a821465fa1e357a6 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-06-06 21:45:30 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-06-06 21:45:30 +0000 git-arc: Use a helper function to fetch boolean config variables Requested by: markj Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D45104 --- tools/tools/git/git-arc.sh | 18 ++++++++++++++---- 1 file 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 @@ -147,6 +147,16 @@ __EOF__ exit 1 } +# +# 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 @@ -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