From 74e8bc59cb324d2d7a55c90195db004219770eec Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 25 Apr 2015 18:47:21 -0700 Subject: merge: handle FETCH_HEAD internally The collect_parents() function now is responsible for 1. parsing the commits given on the command line into a list of commits to be merged; 2. filtering these parents into independent ones; and 3. optionally calling fmt_merge_msg() via prepare_merge_message() to prepare an auto-generated merge log message, using fake contents that FETCH_HEAD would have had if these commits were fetched from the current repository with "git pull . $args..." Make "git merge FETCH_HEAD" to be the same as the traditional git merge "$(git fmt-merge-msg <.git/FETCH_HEAD)" $commits invocation of the command in "git pull", where $commits are the ones that appear in FETCH_HEAD that are not marked as not-for-merge, by making it do a bit more, specifically: - noticing "FETCH_HEAD" is the only "commit" on the command line and picking the commits that are not marked as not-for-merge as the list of commits to be merged (substitute for step #1 above); - letting the resulting list fed to step #2 above; - doing the step #3 above, using the contents of the FETCH_HEAD instead of fake contents crafted from the list of commits parsed in the step #1 above. Note that this changes the semantics. "git merge FETCH_HEAD" has always behaved as if the first commit in the FETCH_HEAD file were directly specified on the command line, creating a two-way merge whose auto-generated merge log said "merge commit xyz". With this change, if the previous fetch was to grab multiple branches (e.g. "git fetch $there topic-a topic-b"), the new world order is to create an octopus, behaving as if "git pull $there topic-a topic-b" were run. This is a deliberate change to make that happen, and can be seen in the changes to t3033 tests. Signed-off-by: Junio C Hamano --- t/t3033-merge-toplevel.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 't') diff --git a/t/t3033-merge-toplevel.sh b/t/t3033-merge-toplevel.sh index 9d92d3c1a..46aadc410 100755 --- a/t/t3033-merge-toplevel.sh +++ b/t/t3033-merge-toplevel.sh @@ -77,7 +77,7 @@ test_expect_success 'merge octopus, non-fast-forward' ' # The same set with FETCH_HEAD -test_expect_failure 'merge FETCH_HEAD octopus into void' ' +test_expect_success 'merge FETCH_HEAD octopus into void' ' t3033_reset && git checkout --orphan test && git rm -fr . && @@ -88,7 +88,7 @@ test_expect_failure 'merge FETCH_HEAD octopus into void' ' test_must_fail git rev-parse HEAD ' -test_expect_failure 'merge FETCH_HEAD octopus fast-forward (ff)' ' +test_expect_success 'merge FETCH_HEAD octopus fast-forward (ff)' ' t3033_reset && git reset --hard one && git fetch . left right && @@ -100,7 +100,7 @@ test_expect_failure 'merge FETCH_HEAD octopus fast-forward (ff)' ' test_cmp expect actual ' -test_expect_failure 'merge FETCH_HEAD octopus non-fast-forward (ff)' ' +test_expect_success 'merge FETCH_HEAD octopus non-fast-forward (ff)' ' t3033_reset && git reset --hard one && git fetch . left right && @@ -112,7 +112,7 @@ test_expect_failure 'merge FETCH_HEAD octopus non-fast-forward (ff)' ' test_cmp expect actual ' -test_expect_failure 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' +test_expect_success 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' t3033_reset && git fetch . left right && git merge FETCH_HEAD && @@ -123,7 +123,7 @@ test_expect_failure 'merge FETCH_HEAD octopus fast-forward (does not ff)' ' test_cmp expect actual ' -test_expect_failure 'merge FETCH_HEAD octopus non-fast-forward' ' +test_expect_success 'merge FETCH_HEAD octopus non-fast-forward' ' t3033_reset && git fetch . left right && git merge --no-ff FETCH_HEAD && -- cgit v1.2.1