]> git.ipfire.org Git - thirdparty/git.git/commitdiff
unpack-trees: do not mark a dirty path with SKIP_WORKTREE
authorElijah Newren <newren@gmail.com>
Fri, 27 Mar 2020 00:48:50 +0000 (00:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Mar 2020 18:33:30 +0000 (11:33 -0700)
If a path is dirty, removing from the working tree risks losing data.
As such, we want to make sure any such path is not marked with
SKIP_WORKTREE.  While the current callers of this code detect this case
and re-populate with a previous set of sparsity patterns, we want to
allow some paths to be marked with SKIP_WORKTREE while others are left
unmarked without it being considered an error.  The reason this
shouldn't be considered an error is that SKIP_WORKTREE has always been
an advisory-only setting; merge and rebase for example were free to
materialize paths and clear the SKIP_WORKTREE bit in order to accomplish
their work even though they kept the SKIP_WORKTREE bit set for other
paths.  Leaving dirty working files in the working tree is thus a
natural extension of what we have already been doing.

Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c

index dde50047a8246bbd97ed0367394ed5648b2a2972..e8e794880ab4e6177d4d04d3f377628e20587978 100644 (file)
@@ -500,8 +500,11 @@ static int apply_sparse_checkout(struct index_state *istate,
                 * also stat info may have lost after merged_entry() so calling
                 * verify_uptodate() again may fail
                 */
-               if (!(ce->ce_flags & CE_UPDATE) && verify_uptodate_sparse(ce, o))
+               if (!(ce->ce_flags & CE_UPDATE) &&
+                   verify_uptodate_sparse(ce, o)) {
+                       ce->ce_flags &= ~CE_SKIP_WORKTREE;
                        return -1;
+               }
                ce->ce_flags |= CE_WT_REMOVE;
                ce->ce_flags &= ~CE_UPDATE;
        }