@@ -334,5 +334,43 @@ public void CanStageIgnoredPaths(string path)
334
334
Assert . Equal ( FileStatus . NewInIndex , repo . RetrieveStatus ( path ) ) ;
335
335
}
336
336
}
337
+
338
+ [ Theory ]
339
+ [ InlineData ( "new_untracked_file.txt" , FileStatus . Ignored ) ]
340
+ [ InlineData ( "modified_unstaged_file.txt" , FileStatus . ModifiedInIndex ) ]
341
+ public void IgnoredFilesAreOnlyStagedIfTheyreInTheRepo ( string filename , FileStatus expected )
342
+ {
343
+ var path = SandboxStandardTestRepoGitDir ( ) ;
344
+ using ( var repo = new Repository ( path ) )
345
+ {
346
+ File . WriteAllText ( Path . Combine ( repo . Info . WorkingDirectory , ".gitignore" ) ,
347
+ String . Format ( "{0}\n " , filename ) ) ;
348
+
349
+ repo . Stage ( filename ) ;
350
+ Assert . Equal ( expected , repo . RetrieveStatus ( filename ) ) ;
351
+ }
352
+ }
353
+
354
+ [ Theory ]
355
+ [ InlineData ( "ancestor-and-ours.txt" , FileStatus . Unaltered ) ]
356
+ [ InlineData ( "ancestor-and-theirs.txt" , FileStatus . NewInIndex ) ]
357
+ [ InlineData ( "ancestor-only.txt" , FileStatus . Nonexistent ) ]
358
+ [ InlineData ( "conflicts-one.txt" , FileStatus . ModifiedInIndex ) ]
359
+ [ InlineData ( "conflicts-two.txt" , FileStatus . ModifiedInIndex ) ]
360
+ [ InlineData ( "ours-only.txt" , FileStatus . Unaltered ) ]
361
+ [ InlineData ( "ours-and-theirs.txt" , FileStatus . ModifiedInIndex ) ]
362
+ [ InlineData ( "theirs-only.txt" , FileStatus . NewInIndex ) ]
363
+ public void CanStageConflictedIgnoredFiles ( string filename , FileStatus expected )
364
+ {
365
+ var path = SandboxMergedTestRepo ( ) ;
366
+ using ( var repo = new Repository ( path ) )
367
+ {
368
+ File . WriteAllText ( Path . Combine ( repo . Info . WorkingDirectory , ".gitignore" ) ,
369
+ String . Format ( "{0}\n " , filename ) ) ;
370
+
371
+ repo . Stage ( filename ) ;
372
+ Assert . Equal ( expected , repo . RetrieveStatus ( filename ) ) ;
373
+ }
374
+ }
337
375
}
338
376
}
0 commit comments