feat(submodule): preserve git's -dirty marker on submodule commits - #2225
Open
nityanand123gupta wants to merge 1 commit into
Open
feat(submodule): preserve git's -dirty marker on submodule commits#2225nityanand123gupta wants to merge 1 commit into
nityanand123gupta wants to merge 1 commit into
Conversation
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.
Problem
When a submodule's working tree has uncommitted changes, git marks the raw diff line with a
-dirtysuffix (+Subproject commit <hash>-dirty). delta's regex already captured this ((-dirty)?) but silently discarded it — the truncated commit hash was rendered identically whether the submodule was dirty or not, so a dirty submodule looked the same as one that had genuinely changed to a different clean commit.Fix
get_submodule_short_commitnow returns(commit, is_dirty)instead of just the commit. The dirty flag is threaded through the existing minus/plus state handling (encoded as a single trailing marker byte in the stored state string, since the commit hash is always exactly 40 hex characters and can't collide with it) and preserved in the final rendered output — so a dirty submodule now displays as e.g.ca030fd1a022..803be42ca46a-dirtyinstead of losing that information entirely.Updated the existing
test_simple_dirty_submodule_difftest, whose fixture already has a-dirtymarked commit, to expect the corrected output.Testing
Ran locally:
cargo test submodule— all 3 submodule tests passing, including the updated dirty-diff testcargo test(full suite) — 415 passed, 0 failedFixes #1838