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

[PATCH 03/11] completion: add tests for 'git config' completion

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 13, 2019, 12:26 UTC
Message-ID
<20190813122652.16468-4-szeder.dev@gmail.com>
In-Reply-To
<20190813122652.16468-1-szeder.dev@gmail.com>

The next patches will change/refactor the way we complete configuration variable names and values, so add a few tests to cover the basics, namely the completion of matching configuration sections, full variable names, and their values.

Note that the test checking the completion of configuration sections is currently failing, though it's not a sign of an actual bug. If a section contains multiple variables, then that section is currently repeated as many times as the number of variables in there. This is not a correctness issue in practice, because Bash's completion facilities remove all repetitions anyway. Consequently, we could list all those repeated sections in the expected output of this test as well, but then it would have to be updated whenever a new configuration variable is added to those sections. Instead, list each matching configuration section only once, mark the test as failing for now, and the next patch will update the completion script to avoid those repetitions.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t9902-completion.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 75512c3403..e15be1164d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1698,6 +1698,27 @@ do
 	'
 done
 
+test_expect_failure 'git config - section' '
+	test_completion "git config br" <<-\EOF
+	branch.Z
+	browser.Z
+	EOF
+'
+
+test_expect_success 'git config - variable name' '
+	test_completion "git config log.d" <<-\EOF
+	log.date Z
+	log.decorate Z
+	EOF
+'
+
+test_expect_success 'git config - value' '
+	test_completion "git config color.pager " <<-\EOF
+	false Z
+	true Z
+	EOF
+'
+
 test_expect_success 'sourcing the completion script clears cached commands' '
 	__git_compute_all_commands &&
 	verbose test -n "$__git_all_commands" &&
-- 
2.23.0.rc2.350.gf4fdc32db7
Previous: SZEDER GáborNext: SZEDER Gábor
Message 5 of 12 in “completion: complete configuration variables and values after 'git -c <TAB>'”
  1. 00/11 completion: complete configuration variables and values after 'git -c <TAB>'SZEDER Gábor, Aug 13, 2019
  2. 01/11 completion: fix a typo in a commentSZEDER Gábor, Aug 13, 2019
  3. 02/11 completion: complete more values of more 'color.*' configuration variablesSZEDER Gábor, Aug 13, 2019
  4. 04/11 completion: deduplicate configuration sectionsSZEDER Gábor, Aug 13, 2019
  5. 03/11 completion: add tests for 'git config' completionSZEDER Gábor, Aug 13, 2019
  6. 05/11 completion: use 'sort -u' to deduplicate config variable namesSZEDER Gábor, Aug 13, 2019
  7. 07/11 completion: split _git_config()SZEDER Gábor, Aug 13, 2019
  8. 06/11 completion: simplify inner 'case' pattern in __gitcomp()SZEDER Gábor, Aug 13, 2019
  9. 08/11 completion: complete configuration sections and variable names for 'git -c'SZEDER Gábor, Aug 13, 2019
  10. 11/11 completion: complete config variables and values for 'git clone --config='SZEDER Gábor, Aug 13, 2019
  11. 10/11 completion: complete config variables names and values for 'git clone -c'SZEDER Gábor, Aug 13, 2019
  12. 09/11 completion: complete values of configuration variables after 'git -c var='SZEDER Gábor, Aug 13, 2019

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.