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

Re: [PATCH 0/4] Re-fix get_pathspec()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2008, 09:37 UTC
Message-ID
<7vve3xv9n9.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1204879119-7528-1-git-send-email-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
> ...
> This miniseries cleans up the interface by making get_pathspec() to die
> again.

By the way, this is meant to also fix the breakage of "git clean" run with a path outside the work tree. With two patches from Dmitry:

 Make private quote_path() in wt-status.c available as quote_path_relative())
 git-clean: correct printing relative path)
on top of the series, the following tests now pass.

-- >8 -- git-clean: add tests for relative path

This adds tests for recent change by Dmitry to fix the report "git clean" gives on removed paths, and also makes sure the command detects paths that is outside working tree.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t7300-clean.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 4037142..afccfc9 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -89,6 +89,58 @@ test_expect_success 'git-clean with prefix' '
 	test -f build/lib.so
 
 '
+
+test_expect_success 'git-clean with relative prefix' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	would_clean=$(
+		cd docs &&
+		git clean -n ../src |
+		sed -n -e "s|^Would remove ||p"
+	) &&
+	test "$would_clean" = ../src/part3.c || {
+		echo "OOps <$would_clean>"
+		false
+	}
+'
+
+test_expect_success 'git-clean with absolute path' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	would_clean=$(
+		cd docs &&
+		git clean -n $(pwd)/../src |
+		sed -n -e "s|^Would remove ||p"
+	) &&
+	test "$would_clean" = ../src/part3.c || {
+		echo "OOps <$would_clean>"
+		false
+	}
+'
+
+test_expect_success 'git-clean with out of work tree relative path' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	(
+		cd docs &&
+		test_must_fail git clean -n ../..
+	)
+'
+
+test_expect_success 'git-clean with out of work tree absolute path' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	dd=$(cd .. && pwd) &&
+	(
+		cd docs &&
+		test_must_fail git clean -n $dd
+	)
+'
+
 test_expect_success 'git-clean -d with prefix and path' '
 
 	mkdir -p build docs src/feature &&
-- 
1.5.4.3.587.g0bdd73
Previous: Junio C Hamano
Message 7 of 7 in “Re-fix get_pathspec()”
  1. 0/4 Re-fix get_pathspec()Junio C Hamano, Mar 7, 2008
  2. 1/4 get_pathspec(): die when an out-of-tree path is givenJunio C Hamano, Mar 7, 2008
  3. Robin RosenbergMar 7, 2008
  4. Junio C HamanoMar 7, 2008
  5. Johannes SchindelinMar 7, 2008
  6. Junio C HamanoMar 7, 2008
  7. Junio C HamanoMar 8, 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.