git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] config: add test cases for empty value and no value config variables.

From
Christian Couder <chriscool@tuxfamily.org>
Date
Feb 7, 2008, 05:23 UTC
Message-ID
<20080207062346.3936cc53.chriscool@tuxfamily.org>

The tests in 't1300-repo-config.sh' did not check what happens when an empty value like the following is used in the config file:

[emptyvalue]
	variable =

Also it was not checked that a variable with no value like the following:

[novalue]
	variable

gives a boolean "true" value, while an ampty value gives a boolean "false" value.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/t1300-repo-config.sh |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index a786c5c..66aeb88 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -283,17 +283,40 @@ test_expect_success '--add' \
 cat > .git/config << EOF
 [novalue]
 	variable
+[emptyvalue]
+	variable =
 EOF
 
 test_expect_success 'get variable with no value' \
 	'git config --get novalue.variable ^$'
 
+test_expect_success 'get variable with empty value' \
+	'git config --get emptyvalue.variable ^$'
+
 echo novalue.variable > expect
 
 test_expect_success 'get-regexp variable with no value' \
 	'git config --get-regexp novalue > output &&
 	 cmp output expect'
 
+echo 'emptyvalue.variable ' > expect
+
+test_expect_success 'get-regexp variable with empty value' \
+	'git config --get-regexp emptyvalue > output &&
+	 cmp output expect'
+
+echo true > expect
+
+test_expect_success 'get bool variable with no value' \
+	'git config --bool novalue.variable > output &&
+	 cmp output expect'
+
+echo false > expect
+
+test_expect_success 'get bool variable with empty value' \
+	'git config --bool emptyvalue.variable > output &&
+	 cmp output expect'
+
 git config > output 2>&1
 
 test_expect_success 'no arguments, but no crash' \
-- 
1.5.4.18.gd0b8
Message 1 of 1 in “config: add test cases for empty value and no value config variables.”
  1. config: add test cases for empty value and no value config variables.Christian Couder, Feb 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.