From a789ca70e7a5b02973b116d21674acd795238f99 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 4 Aug 2014 15:40:19 -0700 Subject: config: teach "git -c" to recognize an empty string In a config file, you can do: [foo] bar to turn the "foo.bar" boolean flag on, and you can do: [foo] bar= to set "foo.bar" to the empty string. However, git's "-c" parameter treats both: git -c foo.bar and git -c foo.bar= as the boolean flag, and there is no way to set a variable to the empty string. This patch enables the latter form to do that. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1300-repo-config.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 967359344d..38917da0ef 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -1006,6 +1006,17 @@ test_expect_success 'git -c "key=value" support' ' test_must_fail git -c name=value config core.name ' +# We just need a type-specifier here that cares about the +# distinction internally between a NULL boolean and a real +# string (because most of git's internal parsers do care). +# Using "--path" works, but we do not otherwise care about +# its semantics. +test_expect_success 'git -c can represent empty string' ' + echo >expect && + git -c foo.empty= config --path foo.empty >actual && + test_cmp expect actual +' + test_expect_success 'key sanity-checking' ' test_must_fail git config foo=bar && test_must_fail git config foo=.bar && -- cgit v1.2.3