Skip to content

Draft: Include 'deleted' files in sparse reapply #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libgit2/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ int git_sparse_checkout__reapply(git_repository *repo, git_sparse *sparse)
/* Don't touch files that aren't current */
if ((error = git_status_file(&status_flags, repo, entry->path)) < 0)
goto done;
if (status_flags != GIT_STATUS_CURRENT)
if (status_flags != GIT_STATUS_CURRENT && status_flags != GIT_STATUS_WT_DELETED)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status_flags are a bitmask, so seeing equality operators is a bit strange.

Stepping back – GIT_STATUS_CURRENT are files where the Index and working directory match the HEAD ref. git reapply doesn't want obliterate an unstaged or staged change. Arguably this should be allowed with a force flag, regardless, the underlying problem is that git_status_file is showing GIT_STATUS_WT_DELETED when a file is missing from the worktree (I'm guessing because it is not in the sparse checkout).

Perhaps the root fix it to modify git_status_file to that it doesn't return GIT_STATUS_WT_DELETE for sparse-no-checkout files?

continue;

if ((error = git_str_joinpath(&fullpath, repo->workdir, entry->path)) < 0)
Expand Down
Loading