summaryrefslogtreecommitdiff
path: root/src/revert.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-11-22 18:02:12 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2013-12-02 16:57:41 -0600
commitbab0b9f2d21d993c3f25ee00ce2d243a4dc0de93 (patch)
tree57e11cab3b255a3fb8a46b00601504a002702f42 /src/revert.c
parent300d192f7ed45112121f2a35d5ca80a4913c7aad (diff)
downloadlibgit2-bab0b9f2d21d993c3f25ee00ce2d243a4dc0de93.tar.gz
clean up state metadata more consistently
Diffstat (limited to 'src/revert.c')
-rw-r--r--src/revert.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/revert.c b/src/revert.c
index 34ba343b6..5660c9919 100644
--- a/src/revert.c
+++ b/src/revert.c
@@ -9,7 +9,6 @@
#include "repository.h"
#include "filebuf.h"
#include "merge.h"
-#include "revert.h"
#include "git2/types.h"
#include "git2/merge.h"
@@ -103,6 +102,13 @@ static int revert_normalize_opts(
return error;
}
+static int revert_state_cleanup(git_repository *repo)
+{
+ const char *state_files[] = { GIT_REVERT_HEAD_FILE, GIT_MERGE_MSG_FILE };
+
+ return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
+}
+
int git_revert(
git_repository *repo,
git_commit *commit,
@@ -175,7 +181,7 @@ int git_revert(
goto done;
on_error:
- git_revert__cleanup(repo);
+ revert_state_cleanup(repo);
done:
git_index_free(index_new);
@@ -188,30 +194,3 @@ done:
return error;
}
-
-int git_revert__cleanup(git_repository *repo)
-{
- int error = 0;
- git_buf revert_head_path = GIT_BUF_INIT,
- merge_msg_path = GIT_BUF_INIT;
-
- assert(repo);
-
- if (git_buf_joinpath(&revert_head_path, repo->path_repository, GIT_REVERT_HEAD_FILE) < 0 ||
- git_buf_joinpath(&merge_msg_path, repo->path_repository, GIT_MERGE_MSG_FILE) < 0)
- return -1;
-
- if (git_path_isfile(revert_head_path.ptr)) {
- if ((error = p_unlink(revert_head_path.ptr)) < 0)
- goto cleanup;
- }
-
- if (git_path_isfile(merge_msg_path.ptr))
- (void)p_unlink(merge_msg_path.ptr);
-
-cleanup:
- git_buf_free(&merge_msg_path);
- git_buf_free(&revert_head_path);
-
- return error;
-}