@@ -151,5 +151,59 @@ public void ResettingTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentA
151
151
repo . Reset ( repo . Lookup < Commit > ( "5b5b025" ) , new [ ] { "new.txt" , "non-existent-path-28.txt" } , new ExplicitPathsOptions ( ) ) ) ;
152
152
}
153
153
}
154
+
155
+ [ Fact ]
156
+ public void CanResetTheIndexWhenARenameExists ( )
157
+ {
158
+ using ( var repo = new Repository ( CloneStandardTestRepo ( ) ) )
159
+ {
160
+ repo . Index . Move ( "branch_file.txt" , "renamed_branch_file.txt" ) ;
161
+ repo . Reset ( repo . Lookup < Commit > ( "32eab9c" ) ) ;
162
+
163
+ RepositoryStatus status = repo . Index . RetrieveStatus ( ) ;
164
+ Assert . Equal ( 0 , status . Where ( IsStaged ) . Count ( ) ) ;
165
+ }
166
+ }
167
+
168
+ [ Fact ]
169
+ public void CanResetSourceOfARenameInIndex ( )
170
+ {
171
+ using ( var repo = new Repository ( CloneStandardTestRepo ( ) ) )
172
+ {
173
+ repo . Index . Move ( "branch_file.txt" , "renamed_branch_file.txt" ) ;
174
+
175
+ RepositoryStatus oldStatus = repo . Index . RetrieveStatus ( ) ;
176
+ Assert . Equal ( 1 , oldStatus . RenamedInIndex . Count ( ) ) ;
177
+ Assert . Equal ( FileStatus . Nonexistent , oldStatus [ "branch_file.txt" ] . State ) ;
178
+ Assert . Equal ( FileStatus . RenamedInIndex , oldStatus [ "renamed_branch_file.txt" ] . State ) ;
179
+
180
+ repo . Reset ( repo . Lookup < Commit > ( "32eab9c" ) , new string [ ] { "branch_file.txt" } ) ;
181
+
182
+ RepositoryStatus newStatus = repo . Index . RetrieveStatus ( ) ;
183
+ Assert . Equal ( 0 , newStatus . RenamedInIndex . Count ( ) ) ;
184
+ Assert . Equal ( FileStatus . Missing , newStatus [ "branch_file.txt" ] . State ) ;
185
+ Assert . Equal ( FileStatus . Added , newStatus [ "renamed_branch_file.txt" ] . State ) ;
186
+ }
187
+ }
188
+
189
+ [ Fact ]
190
+ public void CanResetTargetOfARenameInIndex ( )
191
+ {
192
+ using ( var repo = new Repository ( CloneStandardTestRepo ( ) ) )
193
+ {
194
+ repo . Index . Move ( "branch_file.txt" , "renamed_branch_file.txt" ) ;
195
+
196
+ RepositoryStatus oldStatus = repo . Index . RetrieveStatus ( ) ;
197
+ Assert . Equal ( 1 , oldStatus . RenamedInIndex . Count ( ) ) ;
198
+ Assert . Equal ( FileStatus . RenamedInIndex , oldStatus [ "renamed_branch_file.txt" ] . State ) ;
199
+
200
+ repo . Reset ( repo . Lookup < Commit > ( "32eab9c" ) , new string [ ] { "renamed_branch_file.txt" } ) ;
201
+
202
+ RepositoryStatus newStatus = repo . Index . RetrieveStatus ( ) ;
203
+ Assert . Equal ( 0 , newStatus . RenamedInIndex . Count ( ) ) ;
204
+ Assert . Equal ( FileStatus . Untracked , newStatus [ "renamed_branch_file.txt" ] . State ) ;
205
+ Assert . Equal ( FileStatus . Removed , newStatus [ "branch_file.txt" ] . State ) ;
206
+ }
207
+ }
154
208
}
155
209
}
0 commit comments