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

[PATCH 2/2] dir.c: correct "stuck" logging logic

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 17, 2016, 12:45 UTC
Message-ID
<1458218744-15810-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1458218744-15810-1-git-send-email-pclouds@gmail.com>

Before the last patch, the loop in last_exclude_matching_from_list() looks like this (greatly simplified of course)

   exc = NULL;
   for (...) {
      if (sticky_paths.nr) {
         if (matched) {
            exc = something;
            break;
         }
         continue;
      }
      ...
   }

With this loop, if sticky_paths.nr is non-zero and exc is not NULL, we know we have found a sticky path and can log " (stuck)".

With the last patch, the "continue;" line is removed and that won't work anymore. So explicitly keep track of when to print " (stuck)".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c                                | 4 +++-
 t/t1011-read-tree-sparse-checkout.sh | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dir.c b/dir.c
index 77f38a5..2028094 100644
--- a/dir.c
+++ b/dir.c
@@ -1005,6 +1005,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
 {
 	struct exclude *exc = NULL; /* undecided */
 	int i, maybe_descend = 0;
+	const char *stuck = "";
 
 	if (!el->nr)
 		return NULL;	/* undefined */
@@ -1024,6 +1025,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
 			if (*dtype == DT_UNKNOWN)
 				*dtype = get_dtype(NULL, pathname, pathlen);
 			if (match_sticky(x, pathname, pathlen, *dtype)) {
+				stuck = " (stuck)";
 				exc = x;
 				break;
 			}
@@ -1093,7 +1095,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
 	trace_printf_key(&trace_exclude, "exclude: %.*s vs %s at line %d => %s%s\n",
 			 pathlen, pathname, exc->pattern, exc->srcpos,
 			 exc->flags & EXC_FLAG_NEGATIVE ? "no" : "yes",
-			 exc->sticky_paths.nr ? " (stuck)" : "");
+			 stuck);
 	return exc;
 }
 
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index ecc5e93..f0b856f 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -287,10 +287,14 @@ test_expect_success 'sparse checkout and dir.c sticky bits' '
 		!one/hideme
 		EOF
 		git config core.sparsecheckout true &&
-		git checkout &&
+		GIT_TRACE_EXCLUDE=2 git checkout 2>&1 | grep stuck >stuck-list &&
 		test_path_is_missing one/hideme &&
 		test_path_is_file    one/showme &&
-		test_path_is_file    two/showme
+		test_path_is_file    two/showme &&
+		cat >expected <<-\EOF &&
+		exclude: one/showme vs /* at line 1 => yes (stuck)
+		EOF
+		test_cmp expected stuck-list
 	)
 '
 
-- 
2.8.0.rc0.210.gd302cd2
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 29 of 30 in “bug: sparse config interpretation incorrectness in 2.8.0-rc2”
  1. Durham GoodeMar 17, 2016
  2. Duy NguyenMar 17, 2016
  3. Durham GoodeMar 17, 2016
  4. Junio C HamanoMar 17, 2016
  5. Duy NguyenMar 17, 2016
  6. Johannes SchindelinMar 17, 2016
  7. Duy NguyenMar 17, 2016
  8. Johannes SchindelinMar 17, 2016
  9. Duy NguyenMar 17, 2016
  10. Johannes SchindelinMar 18, 2016
  11. Junio C HamanoMar 17, 2016
  12. Durham GoodeMar 17, 2016
  13. 1/2 dir.c: fix bug in 'nd/exclusion-regression-fix' topicNguyễn Thái Ngọc Duy, Mar 17, 2016
  14. 1/2 dir.c: fix bug in 'nd/exclusion-regression-fix' topicNguyễn Thái Ngọc Duy, Mar 17, 2016
  15. 3/2 dir.c: fix dir re-inclusion rules with "NODIR" and "MUSTBEDIR"Nguyễn Thái Ngọc Duy, Mar 17, 2016
  16. Junio C HamanoMar 17, 2016
  17. Duy NguyenMar 18, 2016
  18. Junio C HamanoMar 18, 2016
  19. Duy NguyenMar 18, 2016
  20. Eric SunshineMar 18, 2016
  21. Durham GoodeMar 18, 2016
  22. Duy NguyenMar 18, 2016
  23. Durham GoodeMar 18, 2016
  24. Duy NguyenMar 18, 2016
  25. Junio C HamanoMar 18, 2016
  26. Extending this cycle by a week and reverting !reinclusion topicJunio C Hamano, Mar 18, 2016
  27. Duy NguyenMar 19, 2016
  28. 2/2 dir.c: correct "stuck" logging logicNguyễn Thái Ngọc Duy, Mar 17, 2016
  29. 2/2 dir.c: correct "stuck" logging logicNguyễn Thái Ngọc Duy, Mar 17, 2016
  30. Junio C HamanoMar 18, 2016

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.