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

[PATCH v2 3/5] Add tests for git status `--ignored=matching`

From
JMJameson Miller <jameson.miller81@gmail.com>
Date
Oct 11, 2017, 13:35 UTC
Message-ID
<20171011133504.15049-4-jamill@microsoft.com>
In-Reply-To
<20171011133504.15049-1-jamill@microsoft.com>

Add tests for new ignored mode (matching) when showing all untracked files.

Signed-off-by: Jameson Miller <jamill@microsoft.com>
---
 t/t7519-ignored-mode.sh | 125 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)
 create mode 100755 t/t7519-ignored-mode.sh
diff --git a/t/t7519-ignored-mode.sh b/t/t7519-ignored-mode.sh
new file mode 100755
index 0000000000..76e91427b0
--- /dev/null
+++ b/t/t7519-ignored-mode.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+test_description='git status collapse ignored'
+
+. ./test-lib.sh
+
+# commit initial ignore file
+test_expect_success 'setup initial commit and ignore file' '
+	cat >.gitignore <<-\EOF &&
+	*.ign
+	ignored_dir/
+	!*.unignore
+	EOF
+	git add . &&
+	git commit -m "Initial commit"
+'
+
+test_expect_success 'Verify behavior of status on folders with ignored files' '
+	test_when_finished "git clean -fdx" &&
+	cat >expect <<-\EOF &&
+	? expect
+	? output
+	! dir/ignored/ignored_1.ign
+	! dir/ignored/ignored_2.ign
+	! ignored/ignored_1.ign
+	! ignored/ignored_2.ign
+	EOF
+
+	mkdir -p ignored dir/ignored &&
+	touch ignored/ignored_1.ign ignored/ignored_2.ign \
+		dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
+
+	git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'Verify status behavior on folder with tracked & ignored files' '
+	test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
+	cat >expect <<-\EOF &&
+	? expect
+	? output
+	! dir/tracked_ignored/ignored_1.ign
+	! dir/tracked_ignored/ignored_2.ign
+	! tracked_ignored/ignored_1.ign
+	! tracked_ignored/ignored_2.ign
+	EOF
+
+	mkdir -p tracked_ignored dir/tracked_ignored &&
+	touch tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
+		tracked_ignored/ignored_1.ign tracked_ignored/ignored_2.ign \
+		dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 \
+		dir/tracked_ignored/ignored_1.ign dir/tracked_ignored/ignored_2.ign &&
+
+	git add tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
+		dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 &&
+	git commit -m "commit tracked files" &&
+
+	git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'Verify status behavior on folder with untracked and ignored files' '
+	test_when_finished "git clean -fdx" &&
+	cat >expect <<-\EOF &&
+	? dir/untracked_ignored/untracked_1
+	? dir/untracked_ignored/untracked_2
+	? expect
+	? output
+	? untracked_ignored/untracked_1
+	? untracked_ignored/untracked_2
+	! dir/untracked_ignored/ignored_1.ign
+	! dir/untracked_ignored/ignored_2.ign
+	! untracked_ignored/ignored_1.ign
+	! untracked_ignored/ignored_2.ign
+	EOF
+
+	mkdir -p untracked_ignored dir/untracked_ignored &&
+	touch untracked_ignored/untracked_1 untracked_ignored/untracked_2 \
+		untracked_ignored/ignored_1.ign untracked_ignored/ignored_2.ign \
+		dir/untracked_ignored/untracked_1 dir/untracked_ignored/untracked_2 \
+		dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign &&
+
+	git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'Verify status matching ignored files on ignored folder' '
+	test_when_finished "git clean -fdx" &&
+	cat >expect <<-\EOF &&
+	? expect
+	? output
+	! ignored_dir/
+	EOF
+
+	mkdir ignored_dir &&
+	touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
+		ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign &&
+
+	git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+	test_i18ncmp expect output
+'
+
+test_expect_success 'Verify status behavior on ignored folder containing tracked file' '
+	test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
+	cat >expect <<-\EOF &&
+	? expect
+	? output
+	! ignored_dir/ignored_1
+	! ignored_dir/ignored_1.ign
+	! ignored_dir/ignored_2
+	! ignored_dir/ignored_2.ign
+	EOF
+
+	mkdir ignored_dir &&
+	touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
+		ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
+		ignored_dir/tracked &&
+	git add -f ignored_dir/tracked &&
+	test_tick &&
+	git commit -m "Force add file in ignored directory" &&
+	git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
+	test_i18ncmp expect output
+'
+
+test_done
-- 
2.13.6
Previous: Junio C HamanoNext: Junio C Hamano
Message 27 of 49 in “Teach Status options around showing ignored files”
  1. 0/6 Teach Status options around showing ignored filesjameson.miller81@gmail.com, Oct 5, 2017
  2. 3/6 Add tests for git status `--ignored=matching`jameson.miller81@gmail.com, Oct 5, 2017
  3. Stefan BellerOct 5, 2017
  4. 5/6 Add tests around status handling of ignored argumentsjameson.miller81@gmail.com, Oct 5, 2017
  5. 6/6 Handle unsupported combination status argumentsjameson.miller81@gmail.com, Oct 5, 2017
  6. Stefan BellerOct 5, 2017
  7. 4/6 Expand support for ignored arguments on statusjameson.miller81@gmail.com, Oct 5, 2017
  8. 1/6 Teach status options around showing ignored filesjameson.miller81@gmail.com, Oct 5, 2017
  9. 2/6 Update documentation for new directory and status logicjameson.miller81@gmail.com, Oct 5, 2017
  10. Stefan BellerOct 5, 2017
  11. Jonathan NiederOct 5, 2017
  12. Jameson MillerOct 5, 2017
  13. 0/5 Teach Status options around showing ignored filesJameson Miller, Oct 11, 2017
  14. 1/5 Teach status options around showing ignored filesJameson Miller, Oct 11, 2017
  15. Junio C HamanoOct 12, 2017
  16. Jameson MillerOct 12, 2017
  17. 2/5 Update documentation for new directory and status logicJameson Miller, Oct 11, 2017
  18. Junio C HamanoOct 12, 2017
  19. Jameson MillerOct 12, 2017
  20. Junio C HamanoOct 13, 2017
  21. 5/5 Add tests around status handling of ignored argumentsJameson Miller, Oct 11, 2017
  22. Junio C HamanoOct 12, 2017
  23. Jameson MillerOct 12, 2017
  24. Junio C HamanoOct 13, 2017
  25. 4/5 Expand support for ignored arguments on statusJameson Miller, Oct 11, 2017
  26. Junio C HamanoOct 12, 2017
  27. 3/5 Add tests for git status `--ignored=matching`Jameson Miller, Oct 11, 2017
  28. Junio C HamanoOct 12, 2017
  29. Jameson MillerOct 12, 2017
  30. 0/4 status: add option to show ignored files differentlyJameson Miller, Oct 19, 2017
  31. 1/4 status: add option to show ignored files differentlyJameson Miller, Oct 19, 2017
  32. Junio C HamanoOct 23, 2017
  33. 2/4 status: report matching ignored and normal untrackedJameson Miller, Oct 19, 2017
  34. 3/4 status: document options to show matching ignored filesJameson Miller, Oct 19, 2017
  35. 4/4 status: test --ignored=matchingJameson Miller, Oct 19, 2017
  36. Stefan BellerOct 19, 2017
  37. Junio C HamanoOct 22, 2017
  38. Junio C HamanoOct 23, 2017
  39. 0/4 status: add option to show ignored files differentlyJameson Miller, Oct 23, 2017
  40. 1/4 status: add option to show ignored files differentlyJameson Miller, Oct 23, 2017
  41. 3/4 status: document options to show matching ignored filesJameson Miller, Oct 23, 2017
  42. 2/4 status: report matching ignored and normal untrackedJameson Miller, Oct 23, 2017
  43. 4/4 status: test ignored modesJameson Miller, Oct 23, 2017
  44. 0/4 status: add option to show ignored files differentlyjameson.miller81@gmail.com, Oct 30, 2017
  45. 3/4 status: document options to show matching ignored filesjameson.miller81@gmail.com, Oct 30, 2017
  46. 4/4 status: test ignored modesjameson.miller81@gmail.com, Oct 30, 2017
  47. 2/4 status: report matching ignored and normal untrackedjameson.miller81@gmail.com, Oct 30, 2017
  48. 1/4 status: add option to show ignored files differentlyjameson.miller81@gmail.com, Oct 30, 2017
  49. Junio C HamanoOct 31, 2017

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.