read-tree --aggressive
A new flag --aggressive resolves what we traditionally resolved with external git-merge-one-file inside index while read-tree 3-way merge works. git-merge-octopus and git-merge-resolve use this flag before running git-merge-index with git-merge-one-file. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
8bc5c04a71
commit
1b1fdf8c2f
@ -90,7 +90,7 @@ do
|
|||||||
NON_FF_MERGE=1
|
NON_FF_MERGE=1
|
||||||
|
|
||||||
echo "Trying simple merge with $SHA1"
|
echo "Trying simple merge with $SHA1"
|
||||||
git-read-tree -u -m $common $MRT $SHA1 || exit 2
|
git-read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2
|
||||||
next=$(git-write-tree 2>/dev/null)
|
next=$(git-write-tree 2>/dev/null)
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
|
@ -38,7 +38,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
git-update-index --refresh 2>/dev/null
|
git-update-index --refresh 2>/dev/null
|
||||||
git-read-tree -u -m $bases $head $remotes || exit 2
|
git-read-tree -u -m --aggressive $bases $head $remotes || exit 2
|
||||||
echo "Trying simple merge."
|
echo "Trying simple merge."
|
||||||
if result_tree=$(git-write-tree 2>/dev/null)
|
if result_tree=$(git-write-tree 2>/dev/null)
|
||||||
then
|
then
|
||||||
|
32
read-tree.c
32
read-tree.c
@ -15,6 +15,7 @@ static int update = 0;
|
|||||||
static int index_only = 0;
|
static int index_only = 0;
|
||||||
static int nontrivial_merge = 0;
|
static int nontrivial_merge = 0;
|
||||||
static int trivial_merges_only = 0;
|
static int trivial_merges_only = 0;
|
||||||
|
static int aggressive = 0;
|
||||||
|
|
||||||
static int head_idx = -1;
|
static int head_idx = -1;
|
||||||
static int merge_size = 0;
|
static int merge_size = 0;
|
||||||
@ -424,11 +425,14 @@ static int threeway_merge(struct cache_entry **stages)
|
|||||||
int df_conflict_remote = 0;
|
int df_conflict_remote = 0;
|
||||||
|
|
||||||
int any_anc_missing = 0;
|
int any_anc_missing = 0;
|
||||||
|
int no_anc_exists = 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < head_idx; i++) {
|
for (i = 1; i < head_idx; i++) {
|
||||||
if (!stages[i])
|
if (!stages[i])
|
||||||
any_anc_missing = 1;
|
any_anc_missing = 1;
|
||||||
|
else
|
||||||
|
no_anc_exists = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = stages[0];
|
index = stages[0];
|
||||||
@ -489,6 +493,29 @@ static int threeway_merge(struct cache_entry **stages)
|
|||||||
if (!head && !remote && any_anc_missing)
|
if (!head && !remote && any_anc_missing)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Under the new "aggressive" rule, we resolve mostly trivial
|
||||||
|
* cases that we historically had git-merge-one-file resolve.
|
||||||
|
*/
|
||||||
|
if (aggressive) {
|
||||||
|
int head_deleted = !head && !df_conflict_head;
|
||||||
|
int remote_deleted = !remote && !df_conflict_remote;
|
||||||
|
/*
|
||||||
|
* Deleted in both.
|
||||||
|
* Deleted in one and unchanged in the other.
|
||||||
|
*/
|
||||||
|
if ((head_deleted && remote_deleted) ||
|
||||||
|
(head_deleted && remote && remote_match) ||
|
||||||
|
(remote_deleted && head && head_match))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Added in both, identically.
|
||||||
|
*/
|
||||||
|
if (no_anc_exists && head && remote && same(head, remote))
|
||||||
|
return merged_entry(head, index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Below are "no merge" cases, which require that the index be
|
/* Below are "no merge" cases, which require that the index be
|
||||||
* up-to-date to avoid the files getting overwritten with
|
* up-to-date to avoid the files getting overwritten with
|
||||||
* conflict resolution files.
|
* conflict resolution files.
|
||||||
@ -677,6 +704,11 @@ int main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(arg, "--aggressive")) {
|
||||||
|
aggressive = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* "-m" stands for "merge", meaning we start in stage 1 */
|
/* "-m" stands for "merge", meaning we start in stage 1 */
|
||||||
if (!strcmp(arg, "-m")) {
|
if (!strcmp(arg, "-m")) {
|
||||||
if (stage || merge)
|
if (stage || merge)
|
||||||
|
Loading…
Reference in New Issue
Block a user