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

[PATCH 1/3] t3700: note a .gitignore matching fault

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
May 2, 2011, 12:55 UTC
Message-ID
<1304340923-15927-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1304340464-14829-1-git-send-email-pclouds@gmail.com>

.gitignore support both positive and negative patterns. One may negate the other. Current code works well if both patterns target files in the same directory.

When a pattern targets a directory and an opposite pattern targets some files/directories within that directory, we need to descend in the directory until we're clear which ones are matched and which are not.

excluded_from_list() fails to handle this case. It too eagerly decides the fate of the whole directory without looking further in.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Sorry, forgot the test name.
 t/t3700-add.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 7de42fa..c9f3a28 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -295,4 +295,20 @@ test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-e
 	test_cmp expect.err actual.err
 '
 
+cat >expected <<EOF
+add 'test/.gitignore'
+add 'test/out/in'
+EOF
+
+test_expect_failure C_LOCALE_OUTPUT 'positive/negative patterns at different dir levels' '
+	mkdir -p test/out &&
+	touch test/out/in test/out/out &&
+	cat >test/.gitignore <<EOF &&
+out
+!out/in
+EOF
+	git add --dry-run test >actual &&
+	test_cmp expected actual
+'
+
 test_done
-- 
1.7.4.74.g639db
Previous: Nguyen Thai Ngoc DuyNext: Johannes Sixt
Message 8 of 18 in “t3700: note a .gitignore matching fault”
  1. 1/3 t3700: note a .gitignore matching faultNguyễn Thái Ngọc Duy, May 2, 2011
  2. 2/3 t1011: fix sparse-checkout initialization and add new fileNguyễn Thái Ngọc Duy, May 2, 2011
  3. 3/3 sparse checkout: do not eagerly decide the fate for whole directoryNguyễn Thái Ngọc Duy, May 2, 2011
  4. Thiago FarinaMay 3, 2011
  5. Nguyen Thai Ngoc DuyMay 3, 2011
  6. Junio C HamanoMay 10, 2011
  7. Nguyen Thai Ngoc DuyMay 11, 2011
  8. 1/3 t3700: note a .gitignore matching faultNguyễn Thái Ngọc Duy, May 2, 2011
  9. Johannes SixtMay 2, 2011
  10. Nguyen Thai Ngoc DuyMay 2, 2011
  11. Junio C HamanoMay 3, 2011
  12. Nguyen Thai Ngoc DuyMay 3, 2011
  13. Junio C HamanoMay 3, 2011
  14. Nguyen Thai Ngoc DuyMay 4, 2011
  15. Nguyen Thai Ngoc DuyMay 4, 2011
  16. Johannes SixtMay 4, 2011
  17. Nguyen Thai Ngoc DuyMay 4, 2011
  18. Junio C HamanoMay 9, 2011

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.