Skip to content

feat(submodule): preserve git's -dirty marker on submodule commits - #2225

Open
nityanand123gupta wants to merge 1 commit into
dandavison:mainfrom
nityanand123gupta:indicate-dirty-submodule-commit
Open

feat(submodule): preserve git's -dirty marker on submodule commits#2225
nityanand123gupta wants to merge 1 commit into
dandavison:mainfrom
nityanand123gupta:indicate-dirty-submodule-commit

Conversation

@nityanand123gupta

Copy link
Copy Markdown

Problem

When a submodule's working tree has uncommitted changes, git marks the raw diff line with a -dirty suffix (+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_commit now 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-dirty instead of losing that information entirely.

Updated the existing test_simple_dirty_submodule_diff test, whose fixture already has a -dirty marked commit, to expect the corrected output.

Testing

Ran locally:

  • cargo test submodule — all 3 submodule tests passing, including the updated dirty-diff test
  • cargo test (full suite) — 415 passed, 0 failed

Fixes #1838

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.

🚀 Indicate submodule dirty state

1 participant