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

[PATCH/RFD 4/3] t7300: Tests for git-clean using filenames with spaces/punctuation

From
MSMichael Spang <mspang@uwaterloo.ca>
Date
May 6, 2007, 18:09 UTC
Message-ID
<463E19F6.9000906@uwaterloo.ca>
In-Reply-To
<463E1705.2090201@gmail.com>
Signed-off-by: Michael Spang <mspang@uwaterloo.ca>
---
This isn't meant for applying, at least until this flaw is fixed.

These tests are failing because ls-files does escaping and clean does not unescape. Does anyone know of a solution to this?

sed could be used to remove the double quotes and replace escaped characters, but doing many replacements happens in multiple passes and hence does not always work as desired.

Is this even properly solvable without making clean a builtin or writing git-unescape?

 t/t7300-clean.sh |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 1fb3850..3792221 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -7,6 +7,8 @@ test_description='git-clean basic tests'
 
 . ./test-lib.sh
 
+TAB="	"
+
 test_expect_success \
     'setup' \
     "mkdir -p src &&
@@ -123,6 +125,27 @@ test_expect_success \
     test ! -e obj.o &&
     test ! -e build"
 
+test_expect_success \
+    'filenames with spaces' \
+    'touch abc\ def &&
+    touch 123 123\  &&
+    git-add 123 &&
+    git-clean &&
+    test ! -e abc\ def &&
+    test ! -e 123\  &&
+    test -e 123'
+
+test_expect_success \
+    'filenames with escaped characters' \
+    'touch "'"$TAB"'" " " \\ \" \\\\\" \\t &&
+    git-clean &&
+    test ! -e "'"$TAB"'" &&
+    test ! -e " " &&
+    test ! -e \\ &&
+    test ! -e \" &&
+    test ! -e \\\\\" &&
+    test ! -e \\t'
+
 test_expect_failure \
     'clean.requireForce' \
     "mkdir -p build docs &&
Previous: Michael SpangNext: Junio C Hamano
Message 6 of 8 in “dir.c: Omit non-excluded directories with dir->show_ignored”
  1. 2/3 dir.c: Omit non-excluded directories with dir->show_ignoredMichael Spang, May 6, 2007
  2. Linus TorvaldsMay 6, 2007
  3. Michael SpangMay 6, 2007
  4. Michael SpangMay 7, 2007
  5. 3/3 Fix minor documentation errorsMichael Spang, May 6, 2007
  6. 4/3 t7300: Tests for git-clean using filenames with spaces/punctuationMichael Spang, May 6, 2007
  7. Junio C HamanoMay 6, 2007
  8. Michael SpangMay 6, 2007

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.