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

Two last-minute changes before 2.46.0 #678

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

derrickstolee
Copy link
Collaborator

These two changes would be nice to have before rebasing onto 2.46.0.

  • Revert b7d6f23 due to the regression it introduced to Git 2.45.0 and the incremental-repack maintenance step. Since git pack-objects --stdin-packs uses a notion of "included" and "excluded" packs, it separates the choice to repack an object from whether or not the multi-pack-index points to the copy in the selected pack-files. Thus, .scalarCaches are filling up with pack-files with fewer than a dozen reference objects, but they still can't be expired with git multi-pack-index expire. This revert fixes the problem but will need more justification, testing, and consideration of the server-side experience when moving upstream.

  • Add an advice message around the sparse index expanding. This commit is already in next in upstream, but just missed the v2.46.0 release window. This advice will be valuable for microsoft/git customers, especially those using the Office monorepo. The commit was cherry-picked from next, but requires an additional change on top to make some microsoft/git-specific tests pass due to comparing stderr.

This reverts commit b7d6f23.

This commit caused a regression in the incremental-repack maintenance
step where not all objects in a pack-file are repacked, thus 'git
multi-pack-index expire' cannot delete the pack-files. This will require
some careful explanation upstream and some careful untangling of how
server-side repacks may be depending on the new logic. Since
microsoft/git only serves client users, it is safe to revert this in
isolation for now.

Signed-off-by: Derrick Stolee <[email protected]>
Typically, forcing a sparse index to expand to a full index means that
Git could not determine the status of a file outside of the
sparse-checkout and needed to expand sparse trees into the full list of
sparse blobs. This operation can be very slow when the sparse-checkout
is much smaller than the full tree at HEAD.

When users are in this state, there is usually a modified or untracked
file outside of the sparse-checkout mentioned by the output of 'git
status'. There are a number of reasons why this is insufficient:

 1. Users may not have a full understanding of which files are inside or
    outside of their sparse-checkout. This is more common in monorepos
    that manage the sparse-checkout using custom tools that map build
    dependencies into sparse-checkout definitions.

 2. In some cases, an empty directory could exist outside the
    sparse-checkout and these empty directories are not reported by 'git
    status' and friends.

 3. If the user has '.gitignore' or 'exclude' files, then 'git status'
    will squelch the warnings and not demonstrate any problems.

In order to help users who are in this state, add a new advice message
to indicate that a sparse index is expanded to a full index. This
message should be written at most once per process, so add a static
global 'give_advice_on_expansion' to sparse-index.c. Further, there is a
case in 'git sparse-checkout set' that uses the sparse index as an
in-memory data structure (even when writing a full index) so we need to
disable the message in that kind of case.

The t1092-sparse-checkout-compatibility.sh test script compares the
behavior of several Git commands across full and sparse repositories,
including sparse repositories with and without a sparse index. We need
to disable the advice in the sparse-index repo to avoid differences in
stderr. By leaving the advice on in the sparse-checkout repo (without
the sparse index), we can test the behavior of disabling the advice in
convert_to_sparse(). (Indeed, these tests are how that necessity was
discovered.) Add a test that reenables the advice and demonstrates that
the message is output.

The advice message is defined outside of expand_index() to avoid super-
wide lines. It is also defined as a macro to avoid compile issues with
-Werror=format-security.

Signed-off-by: Derrick Stolee <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
@derrickstolee derrickstolee requested a review from dscho July 16, 2024 13:18
@derrickstolee derrickstolee self-assigned this Jul 16, 2024
@derrickstolee derrickstolee changed the title Two last-minute commits before 2.46.0 Two last-minute changes before 2.46.0 Jul 16, 2024
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Sounds very good, thank you so much for working on this @derrickstolee !

I left a couple of comments. Before merging, I would to address at least the Scalar Functional Tests failure.

midx-write.c Show resolved Hide resolved
t/t1091-sparse-checkout-builtin.sh Outdated Show resolved Hide resolved
sparse-index.c Show resolved Hide resolved
@derrickstolee
Copy link
Collaborator Author

@dscho I will update my branch with your suggestions after microsoft/scalar#533 merges.

These seem to be custom tests to microsoft/git as they break without
these changes, but these changes are not needed upstream.

Signed-off-by: Derrick Stolee <[email protected]>
@derrickstolee derrickstolee merged commit 6496961 into microsoft:vfs-2.45.2 Jul 16, 2024
48 checks passed
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