Skip to content
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

Sparse Index: upstream updates to git reset #444

Merged
merged 7 commits into from
Oct 13, 2021
Merged

Sparse Index: upstream updates to git reset #444

merged 7 commits into from
Oct 13, 2021

Conversation

vdye
Copy link
Collaborator

@vdye vdye commented Oct 11, 2021

Based on feedback in this patch series, reflecting the current state (V4). Want to integrate this before the bug bash (although things might change after more upstream review).

Changes

  • Commits "replacing" the sparse checkout behavior for mixed reset (first two commits in this series)
  • Fixups with changes based on mailing list feedback
  • An update to force index expansion when the index.sparse config is disabled inline with a command

Rename and invert value of `is_missing` to `is_in_reset_tree` to make the
variable more descriptive of what it represents.

Signed-off-by: Victoria Dye <vdye@github.com>
@vdye vdye self-assigned this Oct 11, 2021
@derrickstolee
Copy link
Collaborator

Good idea to validate things here, too. Thanks!

vdye and others added 6 commits October 12, 2021 09:04
Change `update_index_from_diff` to set `skip-worktree` when applicable for
new index entries. When `git reset --mixed <tree-ish>` is run, entries in
the index with differences between the pre-reset HEAD and reset <tree-ish>
are identified and handled with `update_index_from_diff`. For each file, a
new cache entry in inserted into the index, created from the <tree-ish> side
of the reset (without changing the working tree). However, the newly-created
entry must have `skip-worktree` explicitly set in either of the following
scenarios:

1. the file is in the current index and has `skip-worktree` set
2. the file is not in the current index but is outside of a defined sparse
   checkout definition

Not setting the `skip-worktree` bit leads to likely-undesirable results for
a user. It causes `skip-worktree` settings to disappear on the
"diff"-containing files (but *only* the diff-containing files), leading to
those files now showing modifications in `git status`. For example, when
running `git reset --mixed` in a sparse checkout, some file entries outside
of sparse checkout could show up as deleted, despite the user never deleting
anything (and not wanting them on-disk anyway).

Additionally, add a test to `t7102` to ensure `skip-worktree` is preserved
in a basic `git reset --mixed` scenario and update a failure-documenting
test from 19a0acc (t1092: test interesting sparse-checkout scenarios,
2021-01-23) with new expected behavior.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Victoria Dye <vdye@github.com>
In anticipation of `git reset --hard` being able to use the sparse index
without expanding it, replace the command in `sparse-index is expanded and
converted back` with `git reset -- folder1/a`. This command will need to
expand the index to work properly, even after integrating the rest of
`reset` with sparse index.

Helped-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Add new tests for `--merge` and `--keep` modes, as well as mixed reset with
pathspecs. New performance test cases exercise various execution paths for
`reset`.

Co-authored-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Remove `ensure_full_index` guard on `prime_cache_tree` and update
`prime_cache_tree_rec` to correctly reconstruct sparse directory entries in
the cache tree. While processing a tree's entries, `prime_cache_tree_rec`
must determine whether a directory entry is sparse or not by searching for
it in the index (*without* expanding the index). If a matching sparse
directory index entry is found, no subtrees are added to the cache tree
entry and the entry count is set to 1 (representing the sparse directory
itself). Otherwise, the tree is assumed to not be sparse and its subtrees
are recursively added to the cache tree.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Remove the `ensure_full_index` guard on `read_from_tree` and update `git
reset --mixed` to ensure it can use sparse directory index entries wherever
possible. Sparse directory entries are reset use `diff_tree_oid`, which
requires `change` and `add_remove` functions to process the internal
contents of the sparse directory. The `recursive` diff option handles cases
in which `reset --mixed` must diff/merge files that are nested multiple
levels deep in a sparse directory.

The use of pathspecs with `git reset --mixed` introduces scenarios in which
internal contents of sparse directories may be matched by the pathspec. In
order to reset *all* files in the repo that may match the pathspec, the
following conditions on the pathspec require index expansion before
performing the reset:

* "magic" pathspecs
* wildcard pathspecs that do not match only in-cone files or entire sparse
  directories
* literal pathspecs matching something outside the sparse checkout
  definition

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Update behavior when the `index.sparse` config setting is provided inline to
a command.  Previously would run command on sparse index (unless otherwise
expanded), then write out as sparse. Now, the index will be expanded in the
process of reading it in.

Co-authored-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Victoria Dye <vdye@github.com>
@vdye vdye marked this pull request as ready for review October 13, 2021 13:40
@vdye vdye requested a review from ldennington October 13, 2021 13:40
@vdye vdye merged commit cb40d41 into microsoft:vfs-2.33.0 Oct 13, 2021
dscho pushed a commit that referenced this pull request Oct 30, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Oct 30, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Oct 31, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Nov 4, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Nov 4, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Nov 10, 2021
Sparse Index: upstream updates to `git reset`
derrickstolee pushed a commit that referenced this pull request Nov 15, 2021
Sparse Index: upstream updates to `git reset`
@vdye vdye deleted the reset-upstream-changes branch November 30, 2021 20:20
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 12, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 19, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 20, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 25, 2022
Sparse Index: upstream updates to `git reset`
ldennington pushed a commit to ldennington/git that referenced this pull request Jan 25, 2022
Sparse Index: upstream updates to `git reset`
dscho pushed a commit that referenced this pull request Feb 1, 2022
Sparse Index: upstream updates to `git reset`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants