]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pathspec.c
Merge branch 'ab/ambiguous-object-name'
[thirdparty/git.git] / pathspec.c
index 08f8d3eedc39aa46e8bf3a4cba3220ba9b4e74ab..ddeeba7911496ebc77fe1943b94fdc1d456f17a3 100644 (file)
@@ -37,11 +37,10 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
                        num_unmatched++;
        if (!num_unmatched)
                return;
-       /* TODO: audit for interaction with sparse-index. */
-       ensure_full_index(istate);
        for (i = 0; i < istate->cache_nr; i++) {
                const struct cache_entry *ce = istate->cache[i];
-               if (sw_action == PS_IGNORE_SKIP_WORKTREE && ce_skip_worktree(ce))
+               if (sw_action == PS_IGNORE_SKIP_WORKTREE &&
+                   (ce_skip_worktree(ce) || !path_in_sparse_checkout(ce->name, istate)))
                        continue;
                ce_path_match(istate, ce, pathspec, seen);
        }
@@ -72,7 +71,7 @@ char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec)
 
        for (i = 0; i < istate->cache_nr; i++) {
                struct cache_entry *ce = istate->cache[i];
-               if (ce_skip_worktree(ce))
+               if (ce_skip_worktree(ce) || !path_in_sparse_checkout(ce->name, istate))
                    ce_path_match(istate, ce, pathspec, seen);
        }