git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Glasser <glasser@davidglasser.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: Keep original author with git merge --squash?
Date: Thu, 12 Feb 2015 16:21:56 -0800	[thread overview]
Message-ID: <CAN7QDoKODKwSzWn-Py7zEzbELe4JjoSSjQ7riBRYLcXU-0TLXg@mail.gmail.com> (raw)
In-Reply-To: <CAN7QDoK8ePJW-pM=m0+WpEsiYb_aUdt_YUm3gyBhctY_nWBshA@mail.gmail.com>

On Thu, Feb 12, 2015 at 4:17 PM, David Glasser <glasser@davidglasser.net> wrote:
> On Thu, Feb 12, 2015 at 2:34 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> David Glasser <glasser@davidglasser.net> writes:
>>
>>> So to be concrete: What I'm proposing (and I'm excited to implement
>>> it!) is the following:
>>>
>>> When running "git commit" and:
>>> - You've fallen into the case where the message was read from SQUASH_MSG
>>> - You haven't used another method of specifying the author (--author,
>>>   -C, -c, --amend)
>>> - You have not specified --reset-author
>>> - You have set the "commit.useSquashAuthor" option
>>> - Before invoking prepare-commit-msg, all of the `Author:` lines found
>>>   in SQUASH_MSG have the same value
>>>
>>> then that author is used, as if it were specified with --author.  (And
>>> this will show up, commented-out, at the bottom of COMMIT_EDITMSG.)
>>
>>
>> I actually was hoping that this would extend to cases other than
>> "git merge --squash".
>>
>> When running "git commit" and:
>>
>>  - You didn't use a more explicit method of specifying the
>>    authorship identity (--author, --date, -C, -c --amend,
>>    --reset-author options, or environment variables GIT_AUTHOR_*);
>>
>>  - You have commit.useAuthorFromEditorComment variable;
>>
>>  - You have "# Author: " line that are identical in the result of
>>    the editor,
>>
>> then use that author.  That would allow "git commit --amend" to
>> update a misspelled author name, for example.
>>
>> Is that a bit too liberal?  Would it invite mistakes?
>
> That does sound pretty good.  And for the specific case of squash,
> what I would do would be (a) take one of the existing "Author: " lines
> and turn it into an "# Author:" line and (b) do the ordinary editing
> that I do to combine the existing messages?
>
> (Maybe my proposed "detect that they're all the same" code would run
> at `merge --squash` time, producing a trailing "# Author:" line if all
> of the produced "Author: " lines were identical?)

Or, well, as Peff suggested, maybe SQUASH_MSG should look exactly like
the message that rebase's squash gives you, which in fact is a lot
better: no random indent, "# Author", etc.  So making your suggested
change to parse "# Author" in `git commit`, plus a second change to
make SQUASH_MSG look like rebase's squash, would achieve my goals.


-- 
glasser@davidglasser.net | langtonlabs.org | flickr.com/photos/glasser/

      reply	other threads:[~2015-02-13  0:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 17:21 Keep original author with git merge --squash? David Glasser
2015-02-12  9:28 ` Jeff King
2015-02-12 11:35   ` Michael Haggerty
2015-02-12 12:12     ` Jeff King
2015-02-12 18:42       ` David Glasser
2015-02-12 20:18   ` Junio C Hamano
2015-02-12 20:53     ` David Glasser
2015-02-12 21:23       ` Junio C Hamano
2015-02-12 22:16         ` David Glasser
2015-02-12 22:19           ` David Glasser
2015-02-12 22:34           ` Junio C Hamano
2015-02-12 22:50             ` Jeff King
2015-02-12 23:32               ` Junio C Hamano
2015-02-13  7:10                 ` Jeff King
2015-02-13 19:30                   ` Junio C Hamano
2015-02-13 19:55                     ` Jeff King
2015-02-13  0:17             ` David Glasser
2015-02-13  0:21               ` David Glasser [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAN7QDoKODKwSzWn-Py7zEzbELe4JjoSSjQ7riBRYLcXU-0TLXg@mail.gmail.com \
    --to=glasser@davidglasser.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).