Skip to content

Commit

Permalink
Return non-zero status code if mergeStrings didn't resolve all conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mclaughlinconnor committed Sep 6, 2024
1 parent dbd39be commit f0bdd16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Main {
}
case "cli":
var result = MergeDriver.mergeStrings(args[1], args[2], args[3], Std.parseInt(args[4]));
Sys.print(result);
return 0;
Sys.print(result.diff);
return result.noConflicts ? 0 : 1;
default:
trace("Invalid command");
return -1;
Expand Down
4 changes: 2 additions & 2 deletions src/MergeDriver.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MergeDriver {
See https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver
**/
static public function mergeStrings(base:String, current:String, other:String, opts:Int):String {
static public function mergeStrings(base:String, current:String, other:String, opts:Int):{diff:String, noConflicts:Bool} {
DiffConfig.AUTO_APPLY_NON_CONFLICTED_CHANGES = (opts & (1 << 0)) != 0;
DiffConfig.USE_GREEDY_MERGE_MAGIC_RESOLVE = (opts & (1 << 1)) != 0;
DiffConfig.USE_PATIENCE_ALG = (opts & (1 << 2)) != 0;
Expand All @@ -23,7 +23,7 @@ class MergeDriver {
}

var git = new GitDiff([current, viewer.myModel.getDocument(), other], viewer.myAllMergeChanges);
return git.formatDiff();
return {diff: git.formatDiff(), noConflicts: viewer.getChanges().length == 0};
}

/**
Expand Down

0 comments on commit f0bdd16

Please sign in to comment.