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

Re: Keep original author with git merge --squash?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2015, 23:32 UTC
Message-ID
<xmqqwq3mogdm.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150212225003.GA20763@peff.net>
Jeff King <peff@peff.net> writes:
> What happens if there is no "Author:" line in the output?

I've been assuming that we would do what the current code does. "git commit --amend" for example internally remembers who the original author was and uses that, without paying any attention to the result from the editor. If there is no "Author:", that would not change.

And I do not think we need to be able to say "Oops, I forgot to pass the --reset-author option from the command line", personally, so...

> So probably a saner thing is that a missing "Author:" line does nothing,
yes and
> and using "Author: " (with no text) does a reset.

no (I do not think it is wrong per-se, but I do not think such a good idea).

Show 26 quoted lines
> Also, on the topic of "merge --squash". I never use it myself, but
> having experimented with it due to this thread, I found the template it
> sticks into COMMIT_EDITMSG to be horribly unfriendly for munging. For
> example, with two simple commits, I get:
>
>     Squashed commit of the following:
>     
>     commit 6821a8ac920ed00675e4aec10dcef705211105cd
>     Author: Jeff King <peff@peff.net>
>     Date:   Thu Feb 12 17:39:28 2015 -0500
>     
>         commit subject 2
>     
>         commit body 2
>     
>     commit b0840bb4bbfe00b6ed8c7c4d483f11d126fa2d69
>     Author: Jeff King <peff@peff.net>
>     Date:   Thu Feb 12 17:39:28 2015 -0500
>     
>         commit subject 1
>     
>         commit body 1
>
> I guess that is helpful if you want to keep a complete log of what got
> squashed, but I doubt that is the common case (if you did, then doing a
> real merge would probably be in order).

I think it should show exactly the same thing as "rebase -i" squash insn would give you. People already know how to munge that, right?

> It also raises a question for the proposal in this thread: if there are
> multiple "Author:" lines, which one do we take? The first, or the last?

I was siding with David's "pay attention to in-buffer Author: only when all of them agree". When squash-merging a branch with two or more authors, we would attribute the authorship silently and automatically to you if you do not do anything special otherwise.

Possible alternatives when multiple "Author:"s do not agree are:
 - use you who is playing the integrator;
 - use the tip;
 - use the one that most often appears; or
 - error out and ask the user to leave only one (or zero--if you
   want to take the authorship) by re-attempting "git commit".
Previous: Jeff KingNext: Jeff King
Message 13 of 18 in “Keep original author with git merge --squash?”
  1. David GlasserFeb 11, 2015
  2. Jeff KingFeb 12, 2015
  3. Michael HaggertyFeb 12, 2015
  4. Jeff KingFeb 12, 2015
  5. David GlasserFeb 12, 2015
  6. Junio C HamanoFeb 12, 2015
  7. David GlasserFeb 12, 2015
  8. Junio C HamanoFeb 12, 2015
  9. David GlasserFeb 12, 2015
  10. David GlasserFeb 12, 2015
  11. Junio C HamanoFeb 12, 2015
  12. Jeff KingFeb 12, 2015
  13. Junio C HamanoFeb 12, 2015
  14. Jeff KingFeb 13, 2015
  15. Junio C HamanoFeb 13, 2015
  16. Jeff KingFeb 13, 2015
  17. David GlasserFeb 13, 2015
  18. David GlasserFeb 13, 2015

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.