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

[PATCH] filter-branch: Test renaming directories in a tree-filter

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Mar 31, 2008, 07:14 UTC
Message-ID
<1206947655-20272-1-git-send-email-johannes.sixt@telecom.at>
In-Reply-To
<C46D6D0D-44E1-4976-8956-1D84B6351535@yahoo.ca>
This test currently fails.

If b is a directory then 'mv a b' is not a plain "rename", but really a "move", so we must also test that the directory does not exist with the old name in the directory with the new name.

There's also some cleanup in the corresponding "rename file" test to avoid spurious shell syntax errors and "ambigous ref" error from 'git show' (but these should show up only if the test would fail anyway). Plus we also test for the non-existence of the old file.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 t/t7003-filter-branch.sh |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 6827249..53b5ce6 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
 	make_commit B
 	git checkout -b branch B
 	make_commit D
+	mkdir dir
+	make_commit dir/D
 	make_commit E
 	git checkout master
 	make_commit C
@@ -41,9 +43,23 @@ test_expect_success 'rewrite, renaming a specific file' '
 '
 
 test_expect_success 'test that the file was renamed' '
-	test d = $(git show HEAD:doh) &&
+	test d = "$(git show HEAD:doh --)" &&
+	! test -f d &&
 	test -f doh &&
-	test d = $(cat doh)
+	test d = "$(cat doh)"
+'
+
+test_expect_success 'rewrite, renaming a specific directory' '
+	git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
+'
+
+test_expect_failure 'test that the directory was renamed' '
+	test dir/d = "$(git show HEAD:diroh/d --)" &&
+	! test -d dir &&
+	test -d diroh &&
+	! test -d diroh/dir &&
+	test -f diroh/d &&
+	test dir/d = "$(cat diroh/d)"
 '
 
 git tag oldD HEAD~4
-- 
1.5.4.4
Previous: Jean-François VeilletteNext: Johannes Sixt
Message 3 of 9 in “[bug] filter-branch skipping removed files”
  1. Jean-François VeilletteMar 30, 2008
  2. Jean-François VeilletteMar 30, 2008
  3. filter-branch: Test renaming directories in a tree-filterJohannes Sixt, Mar 31, 2008
  4. filter-branch: Fix renaming a directory in the tree-filterJohannes Sixt, Mar 31, 2008
  5. Johannes SixtMar 31, 2008
  6. Junio C HamanoMar 31, 2008
  7. Johannes SixtMar 31, 2008
  8. Johannes SchindelinMar 31, 2008
  9. Jean-François VeilletteMar 31, 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.