From: David Turner Date: Fri, 31 Jul 2015 17:35:01 +0000 (-0400) Subject: untracked-cache: support sparse checkout X-Git-Tag: v2.6.0-rc0~67^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7687252f3f7def11a862a0fd118c531ee630bd05 untracked-cache: support sparse checkout Remove a check that would disable the untracked cache for sparse checkouts. Add tests that ensure that the untracked cache works with sparse checkouts -- specifically considering the case that a file foo/bar is checked out, but foo/.gitignore is not. Signed-off-by: David Turner Signed-off-by: Junio C Hamano --- diff --git a/dir.c b/dir.c index 8209f8b8af..e7b89fe6fe 100644 --- a/dir.c +++ b/dir.c @@ -1078,10 +1078,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen) (!untracked || !untracked->valid || /* * .. and .gitignore does not exist before - * (i.e. null exclude_sha1 and skip_worktree is - * not set). Then we can skip loading .gitignore, - * which would result in ENOENT anyway. - * skip_worktree is taken care in read_directory() + * (i.e. null exclude_sha1). Then we can skip + * loading .gitignore, which would result in + * ENOENT anyway. */ !is_null_sha1(untracked->exclude_sha1))) { /* @@ -1880,7 +1879,6 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d const struct pathspec *pathspec) { struct untracked_cache_dir *root; - int i; if (!dir->untracked || getenv("GIT_DISABLE_UNTRACKED_CACHE")) return NULL; @@ -1932,15 +1930,6 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d if (dir->exclude_list_group[EXC_CMDL].nr) return NULL; - /* - * An optimization in prep_exclude() does not play well with - * CE_SKIP_WORKTREE. It's a rare case anyway, if a single - * entry has that bit set, disable the whole untracked cache. - */ - for (i = 0; i < active_nr; i++) - if (ce_skip_worktree(active_cache[i])) - return NULL; - if (!ident_in_untracked(dir->untracked)) { warning(_("Untracked cache is disabled on this system.")); return NULL; diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index bd4806c12a..ff23f4e94e 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -354,4 +354,123 @@ EOF test_cmp ../expect ../actual ' +test_expect_success 'set up for sparse checkout testing' ' + echo two >done/.gitignore && + echo three >>done/.gitignore && + echo two >done/two && + git add -f done/two done/.gitignore && + git commit -m "first commit" +' + +test_expect_success 'status after commit' ' + : >../trace && + GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + git status --porcelain >../actual && + cat >../status.expect <../trace.expect <../actual && + cat >../expect <.git/info/sparse-checkout && + test_config core.sparsecheckout true && + git checkout master && + git update-index --untracked-cache && + git status --porcelain >/dev/null && # prime the cache + test_path_is_missing done/.gitignore && + test_path_is_file done/one +' + +test_expect_success 'create files, some of which are gitignored' ' + echo three >done/three && # three is gitignored + echo four >done/four && # four is gitignored at a higher level + echo five >done/five # five is not gitignored +' + +test_expect_success 'test sparse status with untracked cache' ' + : >../trace && + avoid_racy && + GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + git status --porcelain >../status.actual && + cat >../status.expect <../trace.expect <../actual && + cat >../expect <../trace && + GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \ + git status --porcelain >../status.actual && + cat >../status.expect <../trace.expect <