diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2012-10-23 15:42:09 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2012-10-24 20:24:37 -0500 |
| commit | 632d8b230bf38cc61cd70b55a54ae2f52502b4af (patch) | |
| tree | 38a8c4825ab59511951b586edb434a5240f3dc9f /src/merge.c | |
| parent | 6f6b0c013c6eff2aca2a7ada1027044f2e20f578 (diff) | |
| download | libgit2-632d8b230bf38cc61cd70b55a54ae2f52502b4af.tar.gz | |
reset changes for merge
Diffstat (limited to 'src/merge.c')
| -rw-r--r-- | src/merge.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c new file mode 100644 index 000000000..135af6a8c --- /dev/null +++ b/src/merge.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009-2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "repository.h" +#include "buffer.h" +#include "merge.h" +#include "refs.h" +#include "git2/repository.h" +#include "git2/merge.h" +#include "git2/reset.h" + +int git_merge__cleanup(git_repository *repo) +{ + int error = 0; + git_buf merge_head_path = GIT_BUF_INIT, + merge_mode_path = GIT_BUF_INIT, + merge_msg_path = GIT_BUF_INIT; + + assert(repo); + + if (git_buf_joinpath(&merge_head_path, repo->path_repository, GIT_MERGE_HEAD_FILE) < 0 || + git_buf_joinpath(&merge_mode_path, repo->path_repository, GIT_MERGE_MODE_FILE) < 0 || + git_buf_joinpath(&merge_mode_path, repo->path_repository, GIT_MERGE_MODE_FILE) < 0) + return -1; + + if (git_path_isfile(merge_head_path.ptr)) { + if ((error = p_unlink(merge_head_path.ptr)) < 0) + goto cleanup; + } + + if (git_path_isfile(merge_mode_path.ptr)) + (void)p_unlink(merge_mode_path.ptr); + + 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(&merge_mode_path); + git_buf_free(&merge_head_path); + + return error; +} + |
