File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 2
2
{
3
3
public class IsConflictResolved : Command
4
4
{
5
+ private string StatusArgs ;
6
+ private string DiffArgs ;
7
+
5
8
public IsConflictResolved ( string repo , Models . Change change )
6
9
{
7
10
var opt = new Models . DiffOption ( change , true ) ;
8
11
9
12
WorkingDirectory = repo ;
10
13
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 } ";
12
17
}
13
18
14
19
public bool Result ( )
15
20
{
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 ;
17
37
}
18
38
}
19
39
}
You can’t perform that action at this time.
0 commit comments