@@ -61,3 +61,37 @@ export async function stageManualConflictResolution(
6161 assertNever ( chosen , 'unaccounted for git status entry possibility' )
6262 }
6363}
64+
65+ /**
66+ * Stages all resolved conflict files before a checkout operation to prevent
67+ * "error: you need to resolve your current index first" from git.
68+ *
69+ * Handles two kinds of resolved conflicts:
70+ * - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
71+ * - Manual conflicts where the user chose ours/theirs in the Desktop UI
72+ */
73+ export async function stageResolvedConflictFiles (
74+ repository : Repository ,
75+ files : ReadonlyArray < WorkingDirectoryFileChange > ,
76+ manualResolutions : ReadonlyMap < string , ManualConflictResolution >
77+ ) : Promise < void > {
78+ for ( const file of files ) {
79+ const { status } = file
80+ if ( ! isConflictedFileStatus ( status ) ) {
81+ continue
82+ }
83+
84+ const manualResolution = manualResolutions . get ( file . path )
85+
86+ if ( manualResolution !== undefined ) {
87+ // Binary/manual conflict resolved via Desktop UI — stage it
88+ await stageManualConflictResolution ( repository , file , manualResolution )
89+ } else if (
90+ isConflictWithMarkers ( status ) &&
91+ status . conflictMarkerCount === 0
92+ ) {
93+ // Text conflict resolved in external editor — stage it
94+ await addConflictedFile ( repository , file )
95+ }
96+ }
97+ }
0 commit comments