@@ -11,21 +11,22 @@ public struct GitStatusEntry
1111 public string fullPath ;
1212 public string projectPath ;
1313 public string originalPath ;
14- public GitFileStatus status ;
15- public bool staged ;
14+ public GitFileStatus indexStatus ;
15+ public GitFileStatus workTreeStatus ;
1616
17- public GitStatusEntry ( string path , string fullPath , string projectPath , GitFileStatus status ,
18- string originalPath = null , bool staged = false )
17+ public GitStatusEntry ( string path , string fullPath , string projectPath ,
18+ GitFileStatus indexStatus , GitFileStatus workTreeStatus ,
19+ string originalPath = null )
1920 {
2021 Guard . ArgumentNotNullOrWhiteSpace ( path , "path" ) ;
2122 Guard . ArgumentNotNullOrWhiteSpace ( fullPath , "fullPath" ) ;
2223
2324 this . path = path ;
24- this . status = status ;
25+ this . indexStatus = indexStatus ;
26+ this . workTreeStatus = workTreeStatus ;
2527 this . fullPath = fullPath ;
2628 this . projectPath = projectPath ;
2729 this . originalPath = originalPath ;
28- this . staged = staged ;
2930 }
3031
3132 public override int GetHashCode ( )
@@ -35,8 +36,8 @@ public override int GetHashCode()
3536 hash = hash * 23 + ( fullPath ? . GetHashCode ( ) ?? 0 ) ;
3637 hash = hash * 23 + ( projectPath ? . GetHashCode ( ) ?? 0 ) ;
3738 hash = hash * 23 + ( originalPath ? . GetHashCode ( ) ?? 0 ) ;
38- hash = hash * 23 + status . GetHashCode ( ) ;
39- hash = hash * 23 + staged . GetHashCode ( ) ;
39+ hash = hash * 23 + indexStatus . GetHashCode ( ) ;
40+ hash = hash * 23 + workTreeStatus . GetHashCode ( ) ;
4041 return hash ;
4142 }
4243
@@ -54,8 +55,8 @@ public bool Equals(GitStatusEntry other)
5455 String . Equals ( fullPath , other . fullPath ) &&
5556 String . Equals ( projectPath , other . projectPath ) &&
5657 String . Equals ( originalPath , other . originalPath ) &&
57- status == other . status &&
58- staged == other . staged
58+ indexStatus == other . indexStatus &&
59+ workTreeStatus == other . workTreeStatus
5960 ;
6061 }
6162
@@ -78,6 +79,49 @@ public bool Equals(GitStatusEntry other)
7879 return ! ( lhs == rhs ) ;
7980 }
8081
82+ public static GitFileStatus ParseStatusMarker ( char changeFlag )
83+ {
84+ GitFileStatus status = GitFileStatus . None ;
85+ switch ( changeFlag )
86+ {
87+ case 'M' :
88+ status = GitFileStatus . Modified ;
89+ break ;
90+ case 'A' :
91+ status = GitFileStatus . Added ;
92+ break ;
93+ case 'D' :
94+ status = GitFileStatus . Deleted ;
95+ break ;
96+ case 'R' :
97+ status = GitFileStatus . Renamed ;
98+ break ;
99+ case 'C' :
100+ status = GitFileStatus . Copied ;
101+ break ;
102+ case 'U' :
103+ status = GitFileStatus . Unmerged ;
104+ break ;
105+ case 'T' :
106+ status = GitFileStatus . TypeChange ;
107+ break ;
108+ case 'X' :
109+ status = GitFileStatus . Unknown ;
110+ break ;
111+ case 'B' :
112+ status = GitFileStatus . Broken ;
113+ break ;
114+ case '?' :
115+ status = GitFileStatus . Untracked ;
116+ break ;
117+ case '!' :
118+ status = GitFileStatus . Ignored ;
119+ break ;
120+ default : break ;
121+ }
122+ return status ;
123+ }
124+
81125 public string Path => path ;
82126
83127 public string FullPath => fullPath ;
@@ -86,13 +130,18 @@ public bool Equals(GitStatusEntry other)
86130
87131 public string OriginalPath => originalPath ;
88132
89- public GitFileStatus Status => status ;
133+ public GitFileStatus Status => workTreeStatus != GitFileStatus . None ? workTreeStatus : indexStatus ;
134+ public GitFileStatus IndexStatus => indexStatus ;
135+ public GitFileStatus WorkTreeStatus => workTreeStatus ;
136+
137+ public bool Staged => indexStatus != GitFileStatus . None ;
90138
91- public bool Staged => staged ;
139+ public bool Unmerged => ( indexStatus == workTreeStatus && ( indexStatus == GitFileStatus . Added || indexStatus == GitFileStatus . Deleted ) ) ||
140+ indexStatus == GitFileStatus . Unmerged || workTreeStatus == GitFileStatus . Unmerged ;
92141
93142 public override string ToString ( )
94143 {
95- return $ "Path:'{ Path } ' Status:'{ Status } ' FullPath:'{ FullPath } ' ProjectPath:'{ ProjectPath } ' OriginalPath:'{ OriginalPath } ' Staged:'{ Staged } '";
144+ return $ "Path:'{ Path } ' Status:'{ Status } ' FullPath:'{ FullPath } ' ProjectPath:'{ ProjectPath } ' OriginalPath:'{ OriginalPath } ' Staged:'{ Staged } ' Unmerged:' { Unmerged } ' Status:' { IndexStatus } ' Status:' { WorkTreeStatus } ' ";
96145 }
97146 }
98147}
0 commit comments