Implements commands to recompute merge with git merge-file

This commit is contained in:
Henning Dieterichs
2022-08-26 12:01:47 +02:00
parent 16536c25a1
commit 7688a40249
5 changed files with 92 additions and 1 deletions

View File

@@ -656,6 +656,27 @@ export class Git {
private log(output: string): void {
this._onOutput.emit('log', output);
}
async mergeFile(options: { input1Path: string; input2Path: string; basePath: string; diff3?: boolean }): Promise<string> {
const args = ['merge-file', '-p', options.input1Path, options.basePath, options.input2Path];
if (options.diff3) {
args.push('--diff3');
} else {
args.push('--no-diff3');
}
try {
const result = await this.exec('', args);
return result.stdout;
} catch (err) {
if (typeof err.stdout === 'string') {
// The merge had conflicts, stdout still contains the merged result (with conflict markers)
return err.stdout;
} else {
throw err;
}
}
}
}
export interface Commit {