From 60a85a7713febf77069da2a56ac42a418d21f024 Mon Sep 17 00:00:00 2001 From: Flonix Date: Thu, 15 Dec 2011 13:03:48 +0100 Subject: [PATCH] Make Index.Remove() cope with files which have been modified in the working 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) --- LibGit2Sharp.Tests/IndexFixture.cs | 1 + LibGit2Sharp/Index.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs index f91bddaac..32bf1b204 100644 --- a/LibGit2Sharp.Tests/IndexFixture.cs +++ b/LibGit2Sharp.Tests/IndexFixture.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) { diff --git a/LibGit2Sharp/Index.cs b/LibGit2Sharp/Index.cs index c2844385c..900fc1d85 100644 --- a/LibGit2Sharp/Index.cs +++ b/LibGit2Sharp/Index.cs @@ -343,7 +343,7 @@ public void Remove(IEnumerable 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; }