fix(claude-do): merge Modify/Delete- und Rename-Konflikte im Merge sichtbar machen

ClaudeDo-Task: 059bcf98-34d5-4ca0-822d-317980fadf8d
This commit is contained in:
Mika Kuns
2026-08-26 15:46:51 +02:00
3 changed files with 176 additions and 13 deletions
+26
View File
@@ -376,6 +376,32 @@ public sealed class GitService
throw new InvalidOperationException($"git add '{path}' failed (exit {exitCode}): {stderr}");
}
/// <summary>
/// Stages <paramref name="path"/> as deleted (`git rm -f`), removing it from both the index
/// and, if present, the working tree. Used to resolve a merge conflict to "keep the
/// deletion" — unlike <see cref="AddPathAsync"/>, which would stage an empty file as a
/// tracked, zero-byte file rather than actually removing it.
/// </summary>
public async Task RemovePathAsync(string repoDir, string path, CancellationToken ct = default)
{
var (exitCode, _, stderr) = await RunGitAsync(repoDir, ["rm", "-f", "--", path], ct);
if (exitCode != 0)
throw new InvalidOperationException($"git rm '{path}' failed (exit {exitCode}): {stderr}");
}
/// <summary>
/// Content of <paramref name="path"/> at a merge stage (1=base, 2=ours, 3=theirs) via
/// `git show :&lt;stage&gt;:&lt;path&gt;`. Null when that stage doesn't exist for the path —
/// the conventional way to tell a modify/delete or rename/delete conflict apart from an
/// ordinary content conflict (git never writes `&lt;&lt;&lt;&lt;&lt;&lt;&lt;` markers for those,
/// it just leaves whichever side wasn't deleted in the working tree).
/// </summary>
public async Task<string?> ShowConflictStageAsync(string repoDir, int stage, string path, CancellationToken ct = default)
{
var (exitCode, stdout, _) = await RunGitAsync(repoDir, ["show", $":{stage}:{path}"], ct, trimOutput: false);
return exitCode == 0 ? stdout : null;
}
/// <summary>
/// Non-destructive mergeability probe via `git merge-tree --write-tree`. Writes only
/// loose objects — the working tree, index, and refs are left untouched.