File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -373,5 +373,24 @@ public void CanClearTheIndex()
373
373
Assert . Equal ( FileStatus . Removed | FileStatus . Untracked , repo . RetrieveStatus ( testFile ) ) ;
374
374
}
375
375
}
376
+
377
+ [ Theory ]
378
+ [ InlineData ( "new_tracked_file.txt" , FileStatus . Added , FileStatus . Untracked ) ]
379
+ [ InlineData ( "modified_staged_file.txt" , FileStatus . Staged , FileStatus . Removed | FileStatus . Untracked ) ]
380
+ [ InlineData ( "i_dont_exist.txt" , FileStatus . Nonexistent , FileStatus . Nonexistent ) ]
381
+ public void CanRemoveAnEntryFromTheIndex ( string pathInTheIndex , FileStatus expectedBeforeStatus , FileStatus expectedAfterStatus )
382
+ {
383
+ var path = SandboxStandardTestRepoGitDir ( ) ;
384
+ using ( var repo = new Repository ( path ) )
385
+ {
386
+ var before = repo . RetrieveStatus ( pathInTheIndex ) ;
387
+ Assert . Equal ( expectedBeforeStatus , before ) ;
388
+
389
+ repo . Index . Remove ( pathInTheIndex ) ;
390
+
391
+ var after = repo . RetrieveStatus ( pathInTheIndex ) ;
392
+ Assert . Equal ( expectedAfterStatus , after ) ;
393
+ }
394
+ }
376
395
}
377
396
}
Original file line number Diff line number Diff line change @@ -162,6 +162,22 @@ private void RemoveFromIndex(string relativePath)
162
162
Proxy . git_index_remove_bypath ( handle , relativePath ) ;
163
163
}
164
164
165
+ /// <summary>
166
+ /// Removes a specified entry from the index.
167
+ /// </summary>
168
+ /// <param name="indexEntryPath">The path of the <see cref="Index"/> entry to be removed.</param>
169
+ public virtual void Remove ( string indexEntryPath )
170
+ {
171
+ if ( indexEntryPath == null )
172
+ {
173
+ throw new ArgumentNullException ( "indexEntryPath" ) ;
174
+ }
175
+
176
+ RemoveFromIndex ( indexEntryPath ) ;
177
+
178
+ UpdatePhysicalIndex ( ) ;
179
+ }
180
+
165
181
private void UpdatePhysicalIndex ( )
166
182
{
167
183
Proxy . git_index_write ( handle ) ;
You can’t perform that action at this time.
0 commit comments