Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4b3f765a2f38064c0bb221c76c7bb4f28f94a9dc
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4300f8442a276aa48d327b8371af9c2917bd3d5a
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Mar 30, 2021

  1. sparse-index: add guard to ensure full index

    Upcoming changes will introduce modifications to the index format that
    allow sparse directories. It will be useful to have a mechanism for
    converting those sparse index files into full indexes by walking the
    tree at those sparse directories. Name this method ensure_full_index()
    as it will guarantee that the index is fully expanded.
    
    This method is not implemented yet, and instead we focus on the
    scaffolding to declare it and call it at the appropriate time.
    
    Add a 'command_requires_full_index' member to struct repo_settings. This
    will be an indicator that we need the index in full mode to do certain
    index operations. This starts as being true for every command, then we
    will set it to false as some commands integrate with sparse indexes.
    
    If 'command_requires_full_index' is true, then we will immediately
    expand a sparse index to a full one upon reading from disk. This
    suffices for now, but we will want to add more callers to
    ensure_full_index() later.
    
    Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    derrickstolee authored and gitster committed Mar 30, 2021
    Configuration menu
    Copy the full SHA
    3964fc2 View commit details
    Browse the repository at this point in the history
  2. sparse-index: implement ensure_full_index()

    We will mark an in-memory index_state as having sparse directory entries
    with the sparse_index bit. These currently cannot exist, but we will add
    a mechanism for collapsing a full index to a sparse one in a later
    change. That will happen at write time, so we must first allow parsing
    the format before writing it.
    
    Commands or methods that require a full index in order to operate can
    call ensure_full_index() to expand that index in-memory. This requires
    parsing trees using that index's repository.
    
    Sparse directory entries have a specific 'ce_mode' value. The macro
    S_ISSPARSEDIR(ce->ce_mode) can check if a cache_entry 'ce' has this type.
    This ce_mode is not possible with the existing index formats, so we don't
    also verify all properties of a sparse-directory entry, which are:
    
     1. ce->ce_mode == 0040000
     2. ce->flags & CE_SKIP_WORKTREE is true
     3. ce->name[ce->namelen - 1] == '/' (ends in dir separator)
     4. ce->oid references a tree object.
    
    These are all semi-enforced in ensure_full_index() to some extent. Any
    deviation will cause a warning at minimum or a failure in the worst
    case.
    
    Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    derrickstolee authored and gitster committed Mar 30, 2021
    Configuration menu
    Copy the full SHA
    4300f84 View commit details
    Browse the repository at this point in the history
Loading