summaryrefslogtreecommitdiff
path: root/src/merge.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-03-11 17:58:10 -0700
committerEdward Thomson <ethomson@microsoft.com>2014-03-20 09:25:06 -0700
commit1c0b6a38bacb54de300d936338d4adb04a9b311f (patch)
tree8833af717c920b9961fa6e4112bf8909ce60d6e1 /src/merge.c
parentccb308273a8662a9692849115a929bd1a74a15f7 (diff)
downloadlibgit2-1c0b6a38bacb54de300d936338d4adb04a9b311f.tar.gz
Remove fastforward / uptodate from `git_merge`
Diffstat (limited to 'src/merge.c')
-rw-r--r--src/merge.c105
1 files changed, 23 insertions, 82 deletions
diff --git a/src/merge.c b/src/merge.c
index cdc1921ce..b7f043aca 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -1774,31 +1774,20 @@ cleanup:
return error;
}
-static int write_merge_mode(git_repository *repo, unsigned int flags)
+static int write_merge_mode(git_repository *repo)
{
git_filebuf file = GIT_FILEBUF_INIT;
git_buf file_path = GIT_BUF_INIT;
int error = 0;
- /* For future expansion */
- GIT_UNUSED(flags);
-
assert(repo);
if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MODE_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) < 0)
goto cleanup;
- /*
- * no-ff is the only thing allowed here at present. One would
- * presume they would be space-delimited when there are more, but
- * this needs to be revisited.
- */
-
- if (flags & GIT_MERGE_NO_FASTFORWARD) {
- if ((error = git_filebuf_write(&file, "no-ff", 5)) < 0)
- goto cleanup;
- }
+ if ((error = git_filebuf_write(&file, "no-ff", 5)) < 0)
+ goto cleanup;
error = git_filebuf_commit(&file);
@@ -2114,6 +2103,25 @@ cleanup:
return error;
}
+int git_merge__setup(
+ git_repository *repo,
+ const git_merge_head *our_head,
+ const git_merge_head *heads[],
+ size_t heads_len)
+{
+ int error = 0;
+
+ assert (repo && our_head && heads);
+
+ if ((error = write_orig_head(repo, our_head)) == 0 &&
+ (error = write_merge_head(repo, heads, heads_len)) == 0 &&
+ (error = write_merge_mode(repo)) == 0) {
+ error = write_merge_msg(repo, heads, heads_len);
+ }
+
+ return error;
+}
+
/* Merge branches */
static int merge_ancestor_head(
@@ -2147,37 +2155,6 @@ on_error:
return error;
}
-GIT_INLINE(bool) merge_check_uptodate(
- git_merge_result *result,
- const git_merge_head *ancestor_head,
- const git_merge_head *their_head)
-{
- if (git_oid_cmp(&ancestor_head->oid, &their_head->oid) == 0) {
- result->is_uptodate = 1;
- return true;
- }
-
- return false;
-}
-
-GIT_INLINE(bool) merge_check_fastforward(
- git_merge_result *result,
- const git_merge_head *ancestor_head,
- const git_merge_head *our_head,
- const git_merge_head *their_head,
- unsigned int flags)
-{
- if ((flags & GIT_MERGE_NO_FASTFORWARD) == 0 &&
- git_oid_cmp(&ancestor_head->oid, &our_head->oid) == 0) {
- result->is_fastforward = 1;
- git_oid_cpy(&result->fastforward_oid, &their_head->oid);
-
- return true;
- }
-
- return false;
-}
-
const char *merge_their_label(const char *branchname)
{
const char *slash;
@@ -2609,24 +2586,8 @@ int git_merge(
if ((error = merge_normalize_opts(repo, &opts, given_opts, ancestor_head, our_head, their_heads_len, their_heads)) < 0)
goto on_error;
- if (their_heads_len == 1 &&
- ancestor_head != NULL &&
- (merge_check_uptodate(result, ancestor_head, their_heads[0]) ||
- merge_check_fastforward(result, ancestor_head, our_head, their_heads[0], opts.merge_flags))) {
- *out = result;
- goto done;
- }
-
- /* If FASTFORWARD_ONLY is specified, fail. */
- if ((opts.merge_flags & GIT_MERGE_FASTFORWARD_ONLY) ==
- GIT_MERGE_FASTFORWARD_ONLY) {
- giterr_set(GITERR_MERGE, "Not a fast-forward.");
- error = GIT_ENONFASTFORWARD;
- goto on_error;
- }
-
/* Write the merge files to the repository. */
- if ((error = git_merge__setup(repo, our_head, their_heads, their_heads_len, opts.merge_flags)) < 0)
+ if ((error = git_merge__setup(repo, our_head, their_heads, their_heads_len)) < 0)
goto on_error;
if (ancestor_head != NULL &&
@@ -2679,26 +2640,6 @@ done:
return error;
}
-int git_merge__setup(
- git_repository *repo,
- const git_merge_head *our_head,
- const git_merge_head *heads[],
- size_t heads_len,
- unsigned int flags)
-{
- int error = 0;
-
- assert (repo && our_head && heads);
-
- if ((error = write_orig_head(repo, our_head)) == 0 &&
- (error = write_merge_head(repo, heads, heads_len)) == 0 &&
- (error = write_merge_mode(repo, flags)) == 0) {
- error = write_merge_msg(repo, heads, heads_len);
- }
-
- return error;
-}
-
/* Merge result data */
int git_merge_result_is_uptodate(git_merge_result *merge_result)