git-merge: do up-to-date check also for all strategies
This clarifies the logic to omit fast-forward check and omit
trivial merge before running the specified strategy.
The "index_merge" variable started out as a flag to say "do not
do anything clever", but when recursive was changed to skip the
trivial merge, the semantics were changed and the variable alone
does not make sense anymore.
This splits the variable into two, allow_fast_forward (which is
almost always true, and avoids making a merge commit when the
other commit is a descendant of our branch, but is set to false
for ours and subtree) and allow_trivial_merge (which is false
for ours, recursive and subtree).
Unlike the earlier implementation, the "ours" strategy allows an
up-to-date condition. When we are up-to-date, the result will
be our commit, and by definition, we will have our tree as the
result.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-16 08:19:55 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-10-24 10:31:32 +02:00
|
|
|
test_description='merge fast-forward and up to date'
|
git-merge: do up-to-date check also for all strategies
This clarifies the logic to omit fast-forward check and omit
trivial merge before running the specified strategy.
The "index_merge" variable started out as a flag to say "do not
do anything clever", but when recursive was changed to skip the
trivial merge, the semantics were changed and the variable alone
does not make sense anymore.
This splits the variable into two, allow_fast_forward (which is
almost always true, and avoids making a merge commit when the
other commit is a descendant of our branch, but is set to false
for ours and subtree) and allow_trivial_merge (which is false
for ours, recursive and subtree).
Unlike the earlier implementation, the "ours" strategy allows an
up-to-date condition. When we are up-to-date, the result will
be our commit, and by definition, we will have our tree as the
result.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-16 08:19:55 +02:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
>file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git tag c0 &&
|
|
|
|
|
|
|
|
echo second >file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m second &&
|
|
|
|
git tag c1 &&
|
2012-02-13 12:48:56 +01:00
|
|
|
git branch test &&
|
|
|
|
echo third >file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m third &&
|
|
|
|
git tag c2
|
git-merge: do up-to-date check also for all strategies
This clarifies the logic to omit fast-forward check and omit
trivial merge before running the specified strategy.
The "index_merge" variable started out as a flag to say "do not
do anything clever", but when recursive was changed to skip the
trivial merge, the semantics were changed and the variable alone
does not make sense anymore.
This splits the variable into two, allow_fast_forward (which is
almost always true, and avoids making a merge commit when the
other commit is a descendant of our branch, but is set to false
for ours and subtree) and allow_trivial_merge (which is false
for ours, recursive and subtree).
Unlike the earlier implementation, the "ours" strategy allows an
up-to-date condition. When we are up-to-date, the result will
be our commit, and by definition, we will have our tree as the
result.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-16 08:19:55 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge -s recursive up-to-date' '
|
|
|
|
|
|
|
|
git reset --hard c1 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -s recursive c0 &&
|
|
|
|
expect=$(git rev-parse c1) &&
|
|
|
|
current=$(git rev-parse HEAD) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge -s recursive fast-forward' '
|
|
|
|
|
|
|
|
git reset --hard c0 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -s recursive c1 &&
|
|
|
|
expect=$(git rev-parse c1) &&
|
|
|
|
current=$(git rev-parse HEAD) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge -s ours up-to-date' '
|
|
|
|
|
|
|
|
git reset --hard c1 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -s ours c0 &&
|
|
|
|
expect=$(git rev-parse c1) &&
|
|
|
|
current=$(git rev-parse HEAD) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge -s ours fast-forward' '
|
|
|
|
|
|
|
|
git reset --hard c0 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -s ours c1 &&
|
|
|
|
expect=$(git rev-parse c0^{tree}) &&
|
|
|
|
current=$(git rev-parse HEAD^{tree}) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge -s subtree up-to-date' '
|
|
|
|
|
|
|
|
git reset --hard c1 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -s subtree c0 &&
|
|
|
|
expect=$(git rev-parse c1) &&
|
|
|
|
current=$(git rev-parse HEAD) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2012-04-17 21:22:26 +02:00
|
|
|
test_expect_success 'merge fast-forward octopus' '
|
2012-02-13 12:48:56 +01:00
|
|
|
|
|
|
|
git reset --hard c0 &&
|
|
|
|
test_tick &&
|
|
|
|
git merge c1 c2
|
|
|
|
expect=$(git rev-parse c2) &&
|
|
|
|
current=$(git rev-parse HEAD) &&
|
|
|
|
test "$expect" = "$current"
|
|
|
|
'
|
|
|
|
|
git-merge: do up-to-date check also for all strategies
This clarifies the logic to omit fast-forward check and omit
trivial merge before running the specified strategy.
The "index_merge" variable started out as a flag to say "do not
do anything clever", but when recursive was changed to skip the
trivial merge, the semantics were changed and the variable alone
does not make sense anymore.
This splits the variable into two, allow_fast_forward (which is
almost always true, and avoids making a merge commit when the
other commit is a descendant of our branch, but is set to false
for ours and subtree) and allow_trivial_merge (which is false
for ours, recursive and subtree).
Unlike the earlier implementation, the "ours" strategy allows an
up-to-date condition. When we are up-to-date, the result will
be our commit, and by definition, we will have our tree as the
result.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-16 08:19:55 +02:00
|
|
|
test_done
|