From 64c6969b2ff969019fb6e88bdee6973eafe42601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 17 Mar 2016 19:45:43 +0700 Subject: dir.c: correct "stuck" logging logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 = non-NULL; 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 Signed-off-by: Junio C Hamano --- 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 8db53d8ad8..1f845418b4 100644 --- a/dir.c +++ b/dir.c @@ -1013,6 +1013,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 */ @@ -1032,6 +1033,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; } @@ -1101,7 +1103,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 ecc5e930ac..f0b856f14c 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 ) ' -- cgit v1.2.1