Skip to content

Pin diff --submodule=short so Patch reports a moved submodule as its gitlink - #160

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/pin-submodule-format-124
Sep 29, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/pin-submodule-format-124

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #124

Problem

GitPatchBuilder pins several diff settings that change the shape of the output, but not the submodule format. The user's diff.submodule setting controls how a moved submodule appears:

  • With log, git prints Submodule sub a..b: and no diff --git block, so Patch() silently leaves the change out.
  • With diff, git prints the submodule's own files as if they were superproject paths, such as libs/sub/s.txt. Apply(...).ToIndex() then refuses them.

Change

--submodule=short is added to the patch vector next to the existing prefix, color and textconv pins. The short form is the only one that yields a gitlink patch that can be staged.

Tests

  • GitSubmoduleTests.PatchReportsAMovedSubmoduleAsItsGitlinkWhateverDiffSubmoduleSaysAsync has one data row each for log and diff. It moves a submodule checkout by one commit and sets diff.submodule in the superproject's config. It then asserts that Patch() returns exactly one file, libs/sub, and that the file stages through Apply(...).ToIndex().
  • With the fix reverted:
    • log fails with "Sequence contains no elements", because the change is missing
    • diff fails because the path is libs/sub/s.txt, not libs/sub
  • GitPatchBuilderTests.BuildsTheDefaultPatchVector now expects the new argument.
  • With the fix in place, the full suite passes: 729 of 729.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy


Generated by Claude Code

…gitlink [patch]

With diff.submodule=log in the user's config, git prints a moved submodule
as a summary with no diff --git block, so Patch() dropped the change; with
=diff it prints the submodule's own files as superproject paths, which
Apply then refuses. Pin the short form next to the other output pins.

Fixes #124

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy
…sses on Windows

WeakString carries the platform separator, so the raw "libs/sub" literal
failed on windows-latest; the other submodule tests compare typed paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants