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

Commits on Oct 11, 2021

  1. reset: rename is_missing to !is_in_reset_tree

    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 committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    740889e View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2021

  1. reset: preserve skip-worktree bit in mixed reset

    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>
    vdye committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    86c5466 View commit details
    Browse the repository at this point in the history
  2. fixup! sparse-index: update command for expand/collapse test

    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>
    vdye committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    d9d34da View commit details
    Browse the repository at this point in the history
  3. fixup! reset: expand test coverage for sparse checkouts

    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>
    vdye and derrickstolee committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    f5fe8e6 View commit details
    Browse the repository at this point in the history
  4. fixup! sparse-index: make non-mixed reset sparse-aware

    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>
    vdye committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    6a820d6 View commit details
    Browse the repository at this point in the history
  5. fixup! sparse-index: make mixed reset sparse-aware

    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>
    vdye committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    59e04bd View commit details
    Browse the repository at this point in the history
  6. sparse-index: fix index.sparse inline usage

    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 and derrickstolee committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    2dfc887 View commit details
    Browse the repository at this point in the history