This seems to do the trick:
https://gist.github.com/ilovezfs/0c364ceff6f2085ff89c#file-illumos-commit-message-style-awk

Inline example:
git log -n 1 --format=%B | awk 'BEGIN { fout="/dev/stdout" } /^$/ {next} /^Reviewed 
by:|^Approved by:/ { hitreviewsection=1 } !/^Reviewed by:|^Approved by:/ { if (hitreviewsection == 1) 
fout="/dev/null" } { print $0 > fout }' | git commit --amend -F -

On Dec 22, 2015, at 10:41 AM, Matthew Ahrens <mahr...@delphix.com> wrote:

FYI, Currently I'm doing:

git log -n 1 --format=%B | awk '/^$/ {exit} {print $0}' >$tmpfile

Your command worked on a message like:

    6513 partially filled holes lose birth time

    Reviewed by: Matthew Ahrens <mahr...@delphix.com>
    Reviewed by: George Wilson <george.wil...@delphix.com>

    If a ZFS object contains a hole at level one, and then a data block is

results in:
    6513 partially filled holes lose birth time
    Reviewed by: Matthew Ahrens <mahr...@delphix.com>
    Reviewed by: George Wilson <george.wil...@delphix.com>

But it mangles it if there's more than one bug listed (which is rare, but 
valid):

    6513 partially filled holes lose birth time
    1234 another commit

    Reviewed by: Matthew Ahrens <mahr...@delphix.com>
    Reviewed by: George Wilson <george.wil...@delphix.com>

    If a ZFS object contains a hole at level one, and then a data block is

results in:
    6513 partially filled holes lose birth time

Also, if I use it on the current style message, it subtly mangles it:

    6513 partially filled holes lose birth time
    Reviewed by: Matthew Ahrens <mahr...@delphix.com>
    Reviewed by: George Wilson <george.wil...@delphix.com>

    If a ZFS object contains a hole at level one, and then a data block is

results in:
    6513 partially filled holes lose birth time
    Reviewed by: George Wilson <george.wil...@delphix.com>

I'm not great with sed or awk; any ideas how to improve the robustness of this 
script?

--matt

On Tue, Dec 22, 2015 at 6:38 AM, ilove zfs <ilove...@icloud.com> wrote:
Assuming the commit is HEAD and the entire message is exactly how you want it, 
except for the extra line, you should be able to do

git log --pretty=format:"%B" HEAD^..HEAD | sed -e '2,2d' -e '/^$/q' | sed -e 
'/^\s*$/d' | git commit --amend -F -

On Dec 21, 2015, at 11:32 PM, Matthew Ahrens <mahr...@delphix.com> wrote:

It needs that format in illumos. So I would need to augment my script to remove 
the blank line when creating the illumos commit message. Let me know if you can 
help with that. 

--matt 

On Monday, December 21, 2015, ilove zfs <ilove...@icloud.com> wrote:
Even when the original commit has a blank line after the subject, the finalized commits 
seem to always be missing the blank line after the subject. This ends up causing problems 
for git format-patch/git am, git log, git rebase, etc. because the "Reviewed 
by" section is treated as if it's part of the subject. I'm wondering if there's some 
change that could be made to the the RTI commit finalization process to ensure that a 
blank line makes it in there.


Example:
Without a blank line:
bash-3.2$ git log --pretty=format:"%s" HEAD^..HEAD
6529 Properly handle updates of variably-sized SA entries. Reviewed by: Brian Behlendorf 
<behlendo...@llnl.gov> Reviewed by: Matthew Ahrens <mahr...@delphix.com> Reviewed by: Ned 
Bass <ba...@llnl.gov> Reviewed by: Tim Chase <t...@chase2k.com>


With a blank line:
bash-3.2$ git log --pretty=format:"%s" HEAD^..HEAD
6529 Properly handle updates of variably-sized SA entries.


https://github.com/behlendorf/openzfs/commit/ba08234ca691208cc19ae447e6330f263bd93ea3.patch
https://github.com/illumos/illumos-gate/commit/e7e978b1f75353cb29673af9b35453c20c2827bf.patch
https://github.com/openzfs/openzfs/commit/4237281765aa7b431884ef4f566d98bbee07948c.patch


_______________________________________________
developer mailing list
developer@open-zfs.org
http://lists.open-zfs.org/mailman/listinfo/developer

Reply via email to