I like this direction in general.
What happens if there is no "Author:" line in the output? Do we do the equivalent "--reset-author"? That seems slightly error-prone to me. It is not uncommon for me to delete to the end file in my editor to drop cruft (e.g., in an interactive rebase with a "squash" command, I very often drop the final commit message, and it is simpler to just delete to the end of file than to delete to the top of the comment block).
I wonder if we should have some markers in the commented-out section that indicate it even exists, like:
# --- Lines in this section affect the commit authorship ---
# Author: ...
# ---
Of course that is nice when you are editing an existing Author line, but not so much when you have to remember to type that line yourself (because you are adding an author attribution when there was not one before).
So probably a saner thing is that a missing "Author:" line does nothing, and using "Author: " (with no text) does a reset.
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 1I 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). But to munge that into a usable single commit message, I have to:
1. Drop the header fields. We could mark these with "#" instead (which
would also make the "# Author: " proposal here work. 2. Reindent all of the actual message lines!
3. Probably reorder the commit messages, since they are
reverse-chronological here.I would find something like:
# commit b0840bb4bbfe00b6ed8c7c4d483f11d126fa2d69
# Author: Jeff King <peff@peff.net>
# Date: Thu Feb 12 17:39:28 2015 -0500
commit subject 1
commit body 1 # ... and then the second commit ...
much more friendly, and closer to what interactive rebase's squash does. 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 think in the proposed chronological-order format I just showed, it would make sense to take the first.
-Peff