Subject: [PATCH v3 1/3] test-lib-functions: handle --add in test_config

From: "Nipunn Koorapati via GitGitGadget" <[email-masked]>
Date: Mon, 21 Dec 2020 02:05:18 +0000

From: Nipunn Koorapati <[email-masked]>

test_config fails to unset the configuration variable when
using --add, as it tries to run git config --unset-all --add

Tell test_config to invoke test_unconfig with the arg $2 when
the arg $1 is --add

Signed-off-by: Nipunn Koorapati <[email-masked]>
---
 t/test-lib-functions.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 999982fe4a9..1fdd7129d51 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -381,6 +381,7 @@ test_unconfig () {
 		config_dir=$1
 		shift
 	fi
+	echo git ${config_dir:+-C "$config_dir"} config --unset-all "$@"
 	git ${config_dir:+-C "$config_dir"} config --unset-all "$@"
 	config_status=$?
 	case "$config_status" in
@@ -400,7 +401,13 @@ test_config () {
 		config_dir=$1
 		shift
 	fi
-	test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$1'" &&
+
+	first_arg=$1
+	if test "$1" = --add; then
+		first_arg=$2
+	fi
+
+	test_when_finished "test_unconfig ${config_dir:+-C '$config_dir'} '$first_arg'" &&
 	git ${config_dir:+-C "$config_dir"} config "$@"
 }
 
-- 
gitgitgadget