git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git merge branch --no-commit does commit fast forward merges

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 18, 2016, 16:54 UTC
Message-ID
<xmqqtwiy6end.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqy48a6fht.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Andrew Ardill <andrew.ardill@gmail.com> writes:
>
>> I do think that the --no-commit option should imply --no-ff (as this
>> would make the behaviour consistent for end-users). I don't know if
>> this is something that would break scripts etc, but if so you could
>> make it implied only if we detect a terminal or something like is done
>> in other places.
>
> But we are not living in that world.  Making "--no-commit" (which is
> not that "try to populate and show" command) imply "--no-ff" will
> break existing scripts....

Having said all that, there is one change we might want to consider, with a plan to transition to cope with backward incompatibility.

A user who uses "--no-commit" does so with the intention to record a resulting merge after amending the merge result in the working tree. But there is nothing to amend and record, if the same "git merge" without "--no-commit" wouldn't have created a merge commit (there are two cases: (1) the other branch is a descendant of the current branch, (2) the other branch is an ancestor of the current branch).

And the user would want to know that before doing further damange to his history, so we may want to start warn when "--no-commit" fast-forwarded or succeeded with "already up-to-date", with deprecation notice, and eventually want to make it an error.

Those who want to do a scripted
	git merge --no-commit "$1" &&
        autoedit "$1" &&
        git commit

(where the script takes a branch name $1 and uses auto-edit to further record the fact that a branch $1 was merged to somewhere in the contents) would already be buggy if it wants to force no-ff, and will get a warning (and later an error), with such a change. And fixing the script to add "--no-ff" next to "--no-commit" will also stop the new warning/error.

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 21 in “git merge branch --no-commit does commit fast forward merges”
  1. Christoph PaulikApr 17, 2016
  2. Jacob KellerApr 17, 2016
  3. Johannes SchindelinApr 18, 2016
  4. Andrew ArdillApr 18, 2016
  5. Christoph PaulikApr 18, 2016
  6. Andrew ArdillApr 18, 2016
  7. Junio C HamanoApr 18, 2016
  8. Junio C HamanoApr 18, 2016
  9. 1/2 merge: do not contaminate option_commit with --squashJunio C Hamano, Apr 26, 2016
  10. Johannes SchindelinApr 27, 2016
  11. Junio C HamanoApr 27, 2016
  12. Johannes SchindelinApr 27, 2016
  13. 2/2 merge: warn --no-commit merge when no new commit is createdJunio C Hamano, Apr 26, 2016
  14. Stefan BellerApr 26, 2016
  15. Junio C HamanoApr 26, 2016
  16. Eric SunshineApr 27, 2016
  17. Johannes SixtApr 27, 2016
  18. Johannes SchindelinApr 27, 2016
  19. Junio C HamanoApr 27, 2016
  20. Johannes SchindelinApr 27, 2016
  21. Junio C HamanoApr 27, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.