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

[PATCH] t3701-add-interactive: tighten the check of trace output

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Sep 10, 2018, 14:07 UTC
Message-ID
<20180910140714.19617-1-szeder.dev@gmail.com>

The test 'add -p does not expand argument lists' in 't3701-add-interactive.sh', added in 7288e12cce (add--interactive: do not expand pathspecs with ls-files, 2017-03-14), checks the GIT_TRACE of 'git add -p' to ensure that the name of a tracked file wasn't passed around as argument to any of the commands executed as a result of undesired pathspec expansion. This check is done with 'grep' using the filename on its own as the pattern, which is too loose a pattern, and would match any occurrences of the filename in the trace output, not just those as command arguments. E.g. if a developer were to litter the index handling code with trace_printf()s printing, among other things, the name of the just processed cache entry, then that pattern would mistakenly match these as well, and would fail the test.

Tighten this 'grep' pattern to only match trace lines that show the executed commands.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t3701-add-interactive.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 609fbfdc31..65dfbc033a 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -540,7 +540,7 @@ test_expect_success 'add -p does not expand argument lists' '
 	# update it, but we want to be sure that our "." pathspec
 	# was not expanded into the argument list of any command.
 	# So look only for "not-changed".
-	! grep not-changed trace.out
+	! grep -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
 '
 
 test_expect_success 'hunk-editing handles custom comment char' '
-- 
2.19.0.rc2.140.g09cf9e37c9
Next: Taylor Blau
Message 1 of 7 in “t3701-add-interactive: tighten the check of trace output”
  1. t3701-add-interactive: tighten the check of trace outputSZEDER Gábor, Sep 10, 2018
  2. Taylor BlauSep 10, 2018
  3. Taylor BlauSep 18, 2018
  4. Jeff KingSep 10, 2018
  5. Junio C HamanoSep 10, 2018
  6. SZEDER GáborSep 10, 2018
  7. Jeff KingSep 10, 2018

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.