]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/merge.c
merge: handle FETCH_HEAD internally
authorJunio C Hamano <gitster@pobox.com>
Sun, 26 Apr 2015 01:47:21 +0000 (18:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2015 20:27:31 +0000 (13:27 -0700)
commit74e8bc59cb324d2d7a55c90195db004219770eec
tree1ad1ba823e9be15691af9d23e22e3d6ce5839b73
parent770380156dd06cd03d83957d55484f4a98ad284f
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 <gitster@pobox.com>
Documentation/git-merge.txt
builtin/merge.c
t/t3033-merge-toplevel.sh