Update submodules separately to git checkout#21188
Merged
sergiou87 merged 13 commits intodevelopmentfrom Jan 27, 2026
Merged
Conversation
Introduces a helper to set up a repository with an uninitialized submodule and adds a unit test to verify that checking out a branch with such a submodule correctly initializes it. This ensures proper handling of submodules that have not been initialized when switching branches.
Replaces CheckoutWithSubmodulesProgressParser with a more flexible IGitProgressParser interface and updates submodule progress reporting logic. Adjusts progress value scaling for submodule updates in branch and commit checkout functions to improve accuracy and user feedback. Cleans up parser usage in progress-related modules for consistency. Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Introduced clampProgress helper to standardize progress value scaling during branch and commit checkout. Replaced manual progress calculations with clampProgress for improved readability and maintainability. Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Progress reporting for submodule updates during checkout now uses an exponential function based on detected submodule events, providing a more realistic and gradual progress indication when the number of submodules is unknown. Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
Eliminated the enableRecurseSubmodulesFlag feature flag and updated fetch and pull operations to always use the --recurse-submodules option. This simplifies submodule handling and removes unnecessary conditional logic.
Deleted the test for cleaning up submodules that no longer exist from checkout-test.ts. This test is no longer needed or relevant to current functionality.
Enhances the pull logic to update submodules after pulling from a remote, including progress reporting and file protocol support. Adds unit tests to verify submodule initialization, reference updates, and handling of pulls with no submodule changes.
Consolidates submodule update logic into a generic updateSubmodulesAfterOperation function in submodule.ts, replacing operation-specific implementations in checkout.ts and pull.ts. Also moves and generalizes clampProgress to progress.ts for reuse. This improves code maintainability and reduces duplication.
Refactored test helpers and unit tests to use native fs/promises methods and a custom pathExists utility instead of fs-extra. This reduces external dependencies and aligns with modern Node.js practices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#21005
Description
This PR changes how
git checkoutbehaves, and instead of using the--recurse-submodulesargument, it will rungit submodule update --init --recursive.For clarity's sake, the UI will show progress of this task as part of the checkout operation. Users might still run into some edge cases when switching between branches with submodules, but this seems to be an improvement over the previous behavior.
Release notes
Notes: [Fixed] Fix bad repository state when switching between branches with submodules