Pin diff --submodule=short so Patch reports a moved submodule as its gitlink - #160
Merged
Merged
Conversation
…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
|
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.



Fixes #124
Problem
GitPatchBuilderpins several diff settings that change the shape of the output, but not the submodule format. The user'sdiff.submodulesetting controls how a moved submodule appears:log, git printsSubmodule sub a..b:and nodiff --gitblock, soPatch()silently leaves the change out.diff, git prints the submodule's own files as if they were superproject paths, such aslibs/sub/s.txt.Apply(...).ToIndex()then refuses them.Change
--submodule=shortis 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.PatchReportsAMovedSubmoduleAsItsGitlinkWhateverDiffSubmoduleSaysAsynchas one data row each forloganddiff. It moves a submodule checkout by one commit and setsdiff.submodulein the superproject's config. It then asserts thatPatch()returns exactly one file,libs/sub, and that the file stages throughApply(...).ToIndex().logfails with "Sequence contains no elements", because the change is missingdifffails because the path islibs/sub/s.txt, notlibs/subGitPatchBuilderTests.BuildsTheDefaultPatchVectornow expects the new argument.🤖 Generated with Claude Code
https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy
Generated by Claude Code