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

[PATCH] dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkout

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 7, 2010, 18:04 UTC
Message-ID
<1289153098-15684-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<loom.20101107T172926-284@post.gmane.org>

Commit c84de70 (excluded_1(): support exclude files in index - 2009-08-20) tries to work around the fact that there is no directory/file information in index entries, therefore EXC_FLAG_MUSTBEDIR match would fail.

Unfortunately the workaround is flawed. This fixes it.
Reported-by: Thomas Rinderknecht <thomasr@sailguy.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c                                |    3 ++-
 t/t1011-read-tree-sparse-checkout.sh |   10 +++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dir.c b/dir.c
index d1e5e5e..b2dfb69 100644
--- a/dir.c
+++ b/dir.c
@@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,
 
 			if (x->flags & EXC_FLAG_MUSTBEDIR) {
 				if (!dtype) {
-					if (!prefixcmp(pathname, exclude))
+					if (!prefixcmp(pathname, exclude) &&
+					    pathname[x->patternlen] == '/')
 						return to_exclude;
 					else
 						continue;
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index 9a07de1..8008fa2 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -17,17 +17,19 @@ test_expect_success 'setup' '
 	cat >expected <<-\EOF &&
 	100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0	init.t
 	100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0	sub/added
+	100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0	subsub/added
 	EOF
 	cat >expected.swt <<-\EOF &&
 	H init.t
 	H sub/added
+	H subsub/added
 	EOF
 
 	test_commit init &&
 	echo modified >>init.t &&
-	mkdir sub &&
-	touch sub/added &&
-	git add init.t sub/added &&
+	mkdir sub subsub &&
+	touch sub/added subsub/added &&
+	git add init.t sub/added subsub/added &&
 	git commit -m "modified and added" &&
 	git tag top &&
 	git rm sub/added &&
@@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
 	cat >expected.swt-noinit <<-\EOF &&
 	S init.t
 	H sub/added
+	S subsub/added
 	EOF
 
 	echo sub/ > .git/info/sparse-checkout &&
@@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
 	cat >expected.swt-nosub <<-\EOF &&
 	H init.t
 	S sub/added
+	S subsub/added
 	EOF
 
 	echo init.t >.git/info/sparse-checkout &&
-- 
1.7.3.2.210.g045198
Previous: Thomas RinderknechtNext: Thomas Rinderknecht
Message 3 of 6 in “Minor bug with git sparse checkout code”
  1. Thomas RinderknechtNov 7, 2010
  2. Thomas RinderknechtNov 7, 2010
  3. dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkoutNguyễn Thái Ngọc Duy, Nov 7, 2010
  4. Thomas RinderknechtNov 7, 2010
  5. Junio C HamanoNov 8, 2010
  6. Nguyen Thai Ngoc DuyNov 9, 2010

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.