File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22{
33 public class IsConflictResolved : Command
44 {
5+ private string StatusArgs ;
6+ private string DiffArgs ;
7+
58 public IsConflictResolved ( string repo , Models . Change change )
69 {
710 var opt = new Models . DiffOption ( change , true ) ;
811
912 WorkingDirectory = repo ;
1013 Context = repo ;
11- Args = $ "diff -a --ignore-cr-at-eol --check { opt } ";
14+
15+ StatusArgs = $ "--no-optional-locks status --porcelain=v2 -- \" { change . Path } \" ";
16+ DiffArgs = $ "diff -a --ignore-cr-at-eol --check { opt } ";
1217 }
1318
1419 public bool Result ( )
1520 {
16- return ReadToEnd ( ) . IsSuccess ;
21+ // First, check if the file is still "unmerged"...
22+ Args = StatusArgs ;
23+ var rs = ReadToEnd ( ) ;
24+ if ( rs . IsSuccess && rs . StdOut . StartsWith ( "u" ) )
25+ {
26+ // Then, check if the file is a submodule (then we can't use a text-diff).
27+ // Porcelain Format Version 2, Unmerged entry: "u <XY> <N|S><c><m><u> <...>"
28+ if ( rs . StdOut . Substring ( 5 , 1 ) == "S" )
29+ return false ;
30+
31+ // Finally, run a text-diff, checking for conflict-markers.
32+ // (NOTE: Could possibly give false positives for whitespace errors?)
33+ Args = DiffArgs ;
34+ return ReadToEnd ( ) . IsSuccess ;
35+ }
36+ return true ;
1737 }
1838 }
1939}
You can’t perform that action at this time.
0 commit comments