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

[PATCH] t7005: fix subdirectory-filter test

From
Thomas Rast <trast@student.ethz.ch>
Date
Jul 29, 2010, 15:10 UTC
Message-ID
<8fe9ee3cfe2404b719fc0464db9a34c09175052a.1280416055.git.trast@student.ethz.ch>
In-Reply-To
<4C519810.6090108@dbservice.com>

The test would not fail if the filtering failed to do anything, since in

  test -z "$(git diff HEAD directorymoved:newsubdir)"'

'directorymoved:newsubdir' is not valid, so git-diff fails without printing anything on stdout. But then the exit status of git-diff is lost, whereas test -z "" succeeds.

Use 'git diff --exit-code' instead, which does the right thing and has the added bonus of showing the differences if there are any.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Tomas Carnecky wrote:
> Now the test fails. And with the other patch applied on top of it, the
> test passes again.

Ok. Here's a slightly nicer solution, let's add this on top of the earlier patch.

 t/t7003-filter-branch.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index e90da6d..84c2612 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -148,7 +148,8 @@ test_expect_success 'use index-filter to move into a subdirectory' '
 	          GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
 			git update-index --index-info &&
 		  mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
-	test -z "$(git diff HEAD directorymoved:newsubdir)"'
+	git diff --exit-code HEAD directorymoved:newsubdir
+'
 
 test_expect_success 'stops when msg filter fails' '
 	old=$(git rev-parse HEAD) &&
-- 
1.7.2.1.342.g676a4
Previous: Tomas CarneckyNext: Thomas Rast
Message 8 of 13 in “Using filter-branch to move repo contents in subdirectory”
  1. Adam MercerJul 29, 2010
  2. Thomas RastJul 29, 2010
  3. Adam MercerJul 29, 2010
  4. filter-branch tests/docs: avoid \t in sed regexesThomas Rast, Jul 29, 2010
  5. Tomas CarneckyJul 29, 2010
  6. Thomas RastJul 29, 2010
  7. Tomas CarneckyJul 29, 2010
  8. t7005: fix subdirectory-filter testThomas Rast, Jul 29, 2010
  9. Thomas RastJul 29, 2010
  10. Adam MercerAug 9, 2010
  11. Adam MercerAug 11, 2010
  12. Jeff KingAug 11, 2010
  13. Adam MercerAug 11, 2010

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.