Permalink
Browse files

Make Index.Remove() cope with files which have been modified in the w…

…orking directory

Fixes issue #95 - 2/2.

One can't GitRemove a modified file.

$ mkdir test
$ cd test
$ git init .
$ echo "a" > a.txt
$ git add .
$ git commit -m "Initial commit"

$ echo "b" >> a.txt

$ git status
no changes added to commit (use "git add" and/or "git commit -a")

$ git rm a.txt
error: 'a.txt' has local modifications
(use --cached to keep the file, or -f to force removal)
  • Loading branch information...
1 parent fc334d2 commit 60a85a7713febf77069da2a56ac42a418d21f024 @Flonix committed with nulltoken Dec 15, 2011
Showing with 2 additions and 1 deletion.
  1. +1 −0 LibGit2Sharp.Tests/IndexFixture.cs
  2. +1 −1 LibGit2Sharp/Index.cs
@@ -479,6 +479,7 @@ public void CanRemoveAFile(string filename, FileStatus initialStatus, bool shoul
}
[TestCase("deleted_staged_file.txt")]
+ [TestCase("modified_unstaged_file.txt")]
[TestCase("shadowcopy_of_an_unseen_ghost.txt")]
public void RemovingAInvalidFileThrows(string filepath)
{
@@ -343,7 +343,7 @@ public void Remove(IEnumerable<string> paths)
throw new NotImplementedException();
}
- if (!keyValuePair.Value.HasAny(new[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Untracked }))
+ if (!keyValuePair.Value.HasAny(new[] { FileStatus.Nonexistent, FileStatus.Removed, FileStatus.Modified, FileStatus.Untracked }))
{
continue;
}

0 comments on commit 60a85a7

Please sign in to comment.