Merge branch 'ea/merge-code-cleanup'
A loop has been rewritten for conciseness and clarity. * ea/merge-code-cleanup: builtin/merge.c - cleanup of code in for-cycle that tests strategies
This commit is contained in:
commit
dd0bc5b531
@ -892,6 +892,7 @@ static int finish_automerge(struct commit *head,
|
|||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
struct object_id result_commit;
|
struct object_id result_commit;
|
||||||
|
|
||||||
|
write_tree_trivial(result_tree);
|
||||||
free_commit_list(common);
|
free_commit_list(common);
|
||||||
parents = remoteheads;
|
parents = remoteheads;
|
||||||
if (!head_subsumed || fast_forward == FF_NO)
|
if (!head_subsumed || fast_forward == FF_NO)
|
||||||
@ -1586,8 +1587,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
save_state(&stash))
|
save_state(&stash))
|
||||||
oidclr(&stash);
|
oidclr(&stash);
|
||||||
|
|
||||||
for (i = 0; i < use_strategies_nr; i++) {
|
for (i = 0; !merge_was_ok && i < use_strategies_nr; i++) {
|
||||||
int ret;
|
int ret, cnt;
|
||||||
if (i) {
|
if (i) {
|
||||||
printf(_("Rewinding the tree to pristine...\n"));
|
printf(_("Rewinding the tree to pristine...\n"));
|
||||||
restore_state(&head_commit->object.oid, &stash);
|
restore_state(&head_commit->object.oid, &stash);
|
||||||
@ -1604,40 +1605,26 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
ret = try_merge_strategy(use_strategies[i]->name,
|
ret = try_merge_strategy(use_strategies[i]->name,
|
||||||
common, remoteheads,
|
common, remoteheads,
|
||||||
head_commit);
|
head_commit);
|
||||||
if (!option_commit && !ret) {
|
/*
|
||||||
merge_was_ok = 1;
|
* The backend exits with 1 when conflicts are
|
||||||
/*
|
* left to be resolved, with 2 when it does not
|
||||||
* This is necessary here just to avoid writing
|
* handle the given merge at all.
|
||||||
* the tree, but later we will *not* exit with
|
*/
|
||||||
* status code 1 because merge_was_ok is set.
|
if (ret < 2) {
|
||||||
*/
|
if (!ret) {
|
||||||
ret = 1;
|
if (option_commit) {
|
||||||
}
|
/* Automerge succeeded. */
|
||||||
|
automerge_was_ok = 1;
|
||||||
if (ret) {
|
break;
|
||||||
/*
|
|
||||||
* The backend exits with 1 when conflicts are
|
|
||||||
* left to be resolved, with 2 when it does not
|
|
||||||
* handle the given merge at all.
|
|
||||||
*/
|
|
||||||
if (ret == 1) {
|
|
||||||
int cnt = evaluate_result();
|
|
||||||
|
|
||||||
if (best_cnt <= 0 || cnt <= best_cnt) {
|
|
||||||
best_strategy = use_strategies[i]->name;
|
|
||||||
best_cnt = cnt;
|
|
||||||
}
|
}
|
||||||
|
merge_was_ok = 1;
|
||||||
|
}
|
||||||
|
cnt = evaluate_result();
|
||||||
|
if (best_cnt <= 0 || cnt <= best_cnt) {
|
||||||
|
best_strategy = use_strategies[i]->name;
|
||||||
|
best_cnt = cnt;
|
||||||
}
|
}
|
||||||
if (merge_was_ok)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Automerge succeeded. */
|
|
||||||
write_tree_trivial(&result_tree);
|
|
||||||
automerge_was_ok = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user