Skip to content

Commit

Permalink
Make Index.Remove() cope with files which have been modified in the w…
Browse files Browse the repository at this point in the history
…orking directory

Fixes issue libgit2#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
fbezdeka authored and nulltoken committed Dec 15, 2011
1 parent fc334d2 commit 60a85a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions LibGit2Sharp.Tests/IndexFixture.cs
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Index.cs
Expand Up @@ -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;
}
Expand Down

0 comments on commit 60a85a7

Please sign in to comment.