Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2019-08-17 21:41:30 +0300
committerJunio C Hamano <gitster@pobox.com>2019-08-19 20:08:03 +0300
commitb4db8a2b768742f4f43d4a6cdb1db39c2ffc9f7f (patch)
treeed09adf5db7d6e254b5fb76172426f33336b0b15
parent98a1d3d88895a1cbc01b88627776bb4e2bfd6b84 (diff)
merge-recursive: remove useless parameter in merge_trees()
merge_trees() took a results parameter that would only be written when opt->call_depth was positive, which is never the case now that merge_trees_internal() has been split from merge_trees(). Remove the misleading and unused parameter from merge_trees(). While at it, add some comments explaining how the output of merge_trees() and merge_recursive() differ. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/checkout.c4
-rw-r--r--merge-recursive.c6
-rw-r--r--merge-recursive.h20
-rw-r--r--sequencer.c4
4 files changed, 22 insertions, 12 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index d5b946dc3a..90e0eaf25e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -708,7 +708,6 @@ static int merge_working_tree(const struct checkout_opts *opts,
* give up or do a real merge, depending on
* whether the merge flag was used.
*/
- struct tree *result;
struct tree *work;
struct tree *old_tree;
struct merge_options o;
@@ -780,8 +779,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
ret = merge_trees(&o,
new_tree,
work,
- old_tree,
- &result);
+ old_tree);
if (ret < 0)
exit(128);
ret = reset_tree(new_tree,
diff --git a/merge-recursive.c b/merge-recursive.c
index 2a254d5563..4ce783dbfa 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3623,16 +3623,16 @@ static void merge_finalize(struct merge_options *opt)
int merge_trees(struct merge_options *opt,
struct tree *head,
struct tree *merge,
- struct tree *common,
- struct tree **result)
+ struct tree *common)
{
int clean;
+ struct tree *ignored;
assert(opt->ancestor != NULL);
if (merge_start(opt, head))
return -1;
- clean = merge_trees_internal(opt, head, merge, common, result);
+ clean = merge_trees_internal(opt, head, merge, common, &ignored);
merge_finalize(opt);
return clean;
diff --git a/merge-recursive.h b/merge-recursive.h
index f1b6ef38ae..18012fff9d 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -74,19 +74,31 @@ static inline int merge_detect_rename(struct merge_options *o)
o->diff_detect_rename >= 0 ? o->diff_detect_rename : 1;
}
-/* merge_trees() but with recursive ancestor consolidation */
+/*
+ * merge_recursive is like merge_trees() but with recursive ancestor
+ * consolidation, and when successful, it creates an actual commit
+ * and writes its address to *result.
+ *
+ * NOTE: empirically, about a decade ago it was determined that with more
+ * than two merge bases, optimal behavior was found when the
+ * ancestors were passed in the order of oldest merge base to newest
+ * one. Also, ancestors will be consumed (emptied) so make a copy if
+ * you need it.
+ */
int merge_recursive(struct merge_options *o,
struct commit *h1,
struct commit *h2,
struct commit_list *ancestors,
struct commit **result);
-/* rename-detecting three-way merge, no recursion */
+/*
+ * rename-detecting three-way merge, no recursion; result of merge is written
+ * to opt->repo->index.
+ */
int merge_trees(struct merge_options *o,
struct tree *head,
struct tree *merge,
- struct tree *common,
- struct tree **result);
+ struct tree *common);
/*
* "git-merge-recursive" can be fed trees; wrap them into
diff --git a/sequencer.c b/sequencer.c
index 34ebf8ed94..c4ed30f1b4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -586,7 +586,7 @@ static int do_recursive_merge(struct repository *r,
struct replay_opts *opts)
{
struct merge_options o;
- struct tree *result, *next_tree, *base_tree, *head_tree;
+ struct tree *next_tree, *base_tree, *head_tree;
int clean;
char **xopt;
struct lock_file index_lock = LOCK_INIT;
@@ -613,7 +613,7 @@ static int do_recursive_merge(struct repository *r,
clean = merge_trees(&o,
head_tree,
- next_tree, base_tree, &result);
+ next_tree, base_tree);
if (is_rebase_i(opts) && clean <= 0)
fputs(o.obuf.buf, stdout);
strbuf_release(&o.obuf);