feat(merge): Stash-Option fuer uncommittete Aenderungen im Ziel-Tree
Changelog / changelog (push) Successful in 2s
Release / release (push) Successful in 43s

Ein dirty Ziel-Arbeitsverzeichnis gibt jetzt den eigenen Status
dirty_target zurueck statt blocked. Die UI bietet daraufhin einen
Retry an, der per git merge --autostash stasht, merged und die
Aenderungen danach wiederherstellt - opt-in pro Merge:

- Approve & Merge: Bestaetigungsdialog
- Merge-Modal: Button "Aenderungen stashen und mergen"
- MCP (merge_task/review_task) wirft weiterhin, kein autostash dort
This commit is contained in:
mika kuns
2026-09-11 11:43:28 +02:00
parent 8e2d37e63e
commit 251b70ce83
20 changed files with 164 additions and 43 deletions
+11 -3
View File
@@ -424,14 +424,22 @@ public sealed class GitService
return File.Exists(Path.Combine(gitDir, "MERGE_HEAD"));
}
/// <param name="autostash">Stash the target working tree's uncommitted changes before the
/// merge and restore them after it. Git owns the bookkeeping: on a conflict the stash stays
/// pending and is re-applied by `merge --continue`/`--abort`, so a conflicted merge left in
/// the tree doesn't lose it. A restore that itself conflicts leaves the stash in
/// `git stash list` rather than dropping it.</param>
public async Task<(int ExitCode, string Stderr)> MergeNoFfAsync(
string repoDir, string sourceBranch, string message, CancellationToken ct = default)
string repoDir, string sourceBranch, string message, CancellationToken ct = default,
bool autostash = false)
{
// diff3 conflict style writes the merge base (|||||||) into conflict markers so the
// in-app resolver can show a true three-way view. It only enriches conflicted hunks;
// clean merges are unaffected.
var (exitCode, _, stderr) = await RunGitAsync(repoDir,
["-c", "merge.conflictStyle=diff3", "merge", "--no-ff", "-m", message, sourceBranch], ct);
string[] args = autostash
? ["-c", "merge.conflictStyle=diff3", "merge", "--no-ff", "--autostash", "-m", message, sourceBranch]
: ["-c", "merge.conflictStyle=diff3", "merge", "--no-ff", "-m", message, sourceBranch];
var (exitCode, _, stderr) = await RunGitAsync(repoDir, args, ct);
return (exitCode, stderr);
}