fix(merge): refuse a merge that would overwrite an untracked file in the target

Before merging (or staging a conflict resolution's git add -A), compare the
branch's newly-added paths against what's currently untracked in the target
working directory. A collision aborts with a new untracked_collision status
naming the path and size, surfaced through merge_task/review_task,
preview_merge/preview_merge_set (which merge-tree alone can't see), and the
UI merge paths via FlashFooterError/ShowErrorAsync instead of a silent
catch{}. git's own preflight already refuses this while the path stays
untracked at merge time; this closes the gap once a path becomes trackable
in between (e.g. an unrelated conflict resolution's git add -A) or across
the continue_merge TOCTOU window.
This commit is contained in:
mika kuns
2026-08-10 12:15:41 +02:00
parent 6a2a19cc9e
commit afe1b68f46
9 changed files with 269 additions and 13 deletions
@@ -116,6 +116,12 @@ public sealed partial class MergeModalViewModel : ViewModelBase
// point of the gate.
ErrorMessage = result.ErrorMessage ?? Loc.T("vm.merge.verifyFailed");
break;
case "untracked_collision":
// Nothing landed -- the merge was refused before touching the repo. Show the
// real message (it names the colliding path and size); the locale string is
// only a fallback.
ErrorMessage = result.ErrorMessage ?? Loc.T("vm.merge.untrackedCollision");
break;
default:
ErrorMessage = Loc.T("vm.merge.unknownStatus", result.Status);
break;