summaryrefslogtreecommitdiff
path: root/src/reset.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-21 11:54:54 -0700
committerRussell Belfer <rb@github.com>2014-04-21 11:54:54 -0700
commitbd101a7eca6907ab1dd57ae693059466df0da124 (patch)
tree24e8c53f3ea6ec7759162f427089f745237f9e91 /src/reset.c
parent28750a7d98ce5e23bac5c1d119109ded8e8aab73 (diff)
downloadlibgit2-bd101a7eca6907ab1dd57ae693059466df0da124.tar.gz
Fix reset for staged deletes
Diffstat (limited to 'src/reset.c')
-rw-r--r--src/reset.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/reset.c b/src/reset.c
index e403e2a9a..248c91d3a 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -60,13 +60,18 @@ int git_reset_default(
for (i = 0, max_i = git_diff_num_deltas(diff); i < max_i; ++i) {
const git_diff_delta *delta = git_diff_get_delta(diff, i);
- if ((error = git_index_conflict_remove(index, delta->old_file.path)) < 0)
- goto cleanup;
-
assert(delta->status == GIT_DELTA_ADDED ||
delta->status == GIT_DELTA_MODIFIED ||
delta->status == GIT_DELTA_DELETED);
+ error = git_index_conflict_remove(index, delta->old_file.path);
+ if (error < 0) {
+ if (delta->status == GIT_DELTA_ADDED && error == GIT_ENOTFOUND)
+ giterr_clear();
+ else
+ goto cleanup;
+ }
+
if (delta->status == GIT_DELTA_DELETED) {
if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0)
goto cleanup;