@@ -341,7 +341,7 @@ public void CanUnstageTheRemovalOfAFile()
341
341
}
342
342
343
343
[ Fact ]
344
- public void CanUnstageUntrackedFileInAnEmptyRepository ( )
344
+ public void CanUnstageUntrackedFileAgainstAnOrphanedHead ( )
345
345
{
346
346
SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
347
347
@@ -360,6 +360,41 @@ public void CanUnstageUntrackedFileInAnEmptyRepository()
360
360
}
361
361
}
362
362
363
+ [ Fact ]
364
+ public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows ( )
365
+ {
366
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
367
+ TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoWorkingDirPath ) ;
368
+ using ( var repo = new Repository ( path . RepositoryPath ) )
369
+ {
370
+ DirectoryInfo di = Directory . CreateDirectory ( scd . DirectoryPath ) ;
371
+
372
+ const string filename = "unit_test.txt" ;
373
+ string fullPath = Path . Combine ( di . FullName , filename ) ;
374
+ File . WriteAllText ( fullPath , "some contents" ) ;
375
+
376
+ Assert . Throws < ArgumentException > ( ( ) => repo . Index . Unstage ( fullPath ) ) ;
377
+ }
378
+ }
379
+
380
+ [ Fact ]
381
+ public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirAgainstAnOrphanedHeadThrows ( )
382
+ {
383
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
384
+ SelfCleaningDirectory scd2 = BuildSelfCleaningDirectory ( ) ;
385
+
386
+ using ( var repo = Repository . Init ( scd2 . DirectoryPath ) )
387
+ {
388
+ DirectoryInfo di = Directory . CreateDirectory ( scd . DirectoryPath ) ;
389
+
390
+ const string filename = "unit_test.txt" ;
391
+ string fullPath = Path . Combine ( di . FullName , filename ) ;
392
+ File . WriteAllText ( fullPath , "some contents" ) ;
393
+
394
+ Assert . Throws < ArgumentException > ( ( ) => repo . Index . Unstage ( fullPath ) ) ;
395
+ }
396
+ }
397
+
363
398
[ Fact ]
364
399
public void UnstagingFileWithBadParamsThrows ( )
365
400
{
0 commit comments