Skip to content

Indicate dirty state in short-format submodule diffs - #2209

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

Indicate dirty state in short-format submodule diffs#2209
MsfPablo wants to merge 1 commit into
dandavison:mainfrom
MsfPablo:indicate-submodule-dirty-state

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Aug 7, 2026

Copy link
Copy Markdown

Summary

When diff.submodule = short (the default), a dirty submodule shows:

-Subproject commit ca030fd1a02225a6fc1a834c480276d9c97a8c6f
+Subproject commit 803be42ca46af0fbc65b54a9abfb499389516939-dirty

get_submodule_short_commit matched the optional -dirty suffix but only
ever returned the hash capture group, discarding the flag. So delta
rendered a dirty submodule identically to a clean one — just
<red hash>..<green hash> — which is exactly the ambiguity described in #1838.

This propagates the dirty flag through and appends -dirty to the
printed commit range when the working-tree side is dirty:

ca030fd1a022..803be42ca46a-dirty

Test plan

  • cargo test — 438 passed, 0 failed
  • Updated test_simple_dirty_submodule_diff to assert the -dirty suffix is rendered
  • cargo fmt --check clean
  • cargo clippy --all-targets — no new warnings introduced (pre-existing warnings are in unrelated utils/process.rs)

Fixes #1838

get_submodule_short_commit discarded the "-dirty" suffix git appends
to the "+Subproject commit <hash>-dirty" line, so a dirty submodule
rendered identically to a clean one (just red hash..green hash).

Propagate the dirty flag and append "-dirty" to the printed commit
range so it's visible again.

Fixes dandavison#1838
@MsfPablo

Copy link
Copy Markdown
Author

Following up on this one. It surfaces the dirty marker in short-format submodule diffs, matching what git itself shows. Glad to add a test case if that'd help review.

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