New mklog script

Richard Earnshaw Richard.Earnshaw@foss.arm.com
Tue May 26 10:23:24 GMT 2020


On 25/05/2020 20:41, Jason Merrill via Gcc-patches wrote:
> On Mon, May 25, 2020 at 5:23 AM Martin Liška <mliska@suse.cz> wrote:
>>
>> On 5/22/20 11:01 PM, Jason Merrill wrote:
>>> On Thu, May 21, 2020 at 6:03 PM Jason Merrill <jason@redhat.com> wrote:
>>>>
>>>> On Fri, May 15, 2020 at 11:39 AM Martin Liška <mliska@suse.cz> wrote:
>>>>>
>>>>> On 5/15/20 3:22 PM, Marek Polacek wrote:
>>>>>> On Fri, May 15, 2020 at 03:12:27PM +0200, Martin Liška wrote:
>>>>>>> On 5/15/20 2:42 PM, Marek Polacek wrote:
>>>>>>>> I actually use mklog -i all the time.  But I can work around it if it
>>>>>>>> disappears.
>>>>>>>
>>>>>>> Ah, I can see a consumer.
>>>>>>> There's an updated version that supports that.
>>>>>>>
>>>>>>> For the future, will you still use the option? Wouldn't be better
>>>>>>> to put the ChangeLog content directly to commit message? Note
>>>>>>> that you won't have to copy the entries to a particular ChangeLog file.
>>>>>>
>>>>>> The way I do it is to generate a patch using format-patch, use mklog -i
>>>>>> on it, then add the ChangeLog entry to the commit message via commit --amend.
>>>>>
>>>>> Hmm, you can do much better with:
>>>>>
>>>>> $ git diff | ./contrib/mklog > changelog && git commit -a -t changelog
>>>>>
>>>>> Or for an already created commit you can do:
>>>>>
>>>>> $ git diff HEAD~ | ./contrib/mklog > changelog && git commit -a --amend -e -F changelog
>>>>
>>>> With these git aliases:
>>>>
>>>>          mklog-editor = "!f() { git show | git gcc-mklog >> $1; }; f"
>>>>          addlog = "!f() { GIT_EDITOR='git mklog-editor' git commit --amend; }; f"
>>>>
>>>> I can 'git addlog' to append the output of mklog to the current
>>>> commit.  Probably better would be to do something with
>>>> prepare-commit-msg.
>>>
>>> This is pretty rudimentary, but good enough as a start:
>>
>> I like the idea of usage of the prepare commit hook.
>>
>>>
>>> #!/bin/sh
>>>
>>> #COMMIT_MSG_FILE=$1
>>> #COMMIT_SOURCE=$2
>>> #SHA1=$3
>>
>> It's better to use the named arguments.
>>
>>>
>>> if ! [ -f "$1" ]; then exit 0; fi
>>>
>>> #echo "# $0 $1 $2 $3" >> $1
>>>
>>> if fgrep 'ChangeLog:' $1 > /dev/null 2>&1; then exit 0; fi
>>>
>>> if [ -z "$2" ]; then
>>>      cmd="diff --cached"
>>> elif [ $2 == commit ]; then
>>>      cmd="show $3"
>>> else
>>>      exit 0
>>> fi
>>>
>>> git $cmd | git gcc-mklog >> $1
>>>
>>
>> Well, that will generate changelog entry for each commit.
>> For a user branch development, it's not desirable.
> 
> It isn't that useful for intermediate commits, but I was thinking it
> wasn't harmful either.  But I can remove the on-by-default aspects.
> 
>> What about more explicit approach:
>>
>> 1) making an alias for: git diff | git gcc-mklog > commit.msg
>> 2) hook:
>>
>> if test -f commit.msg; then
>>    cat commit.msg >> "$COMMIT_MSG_FILE"
>>    rm commit.msg
>> fi
>>
>> So the changelog is created explicitly and included implicitly.
> 
> How about this?
> 

> +git config alias.commit-mklog '!f() { GCC_FORCE_MKLOG=1 git commit
"$@"; }; f'
> +

I thought we had a convention that aliases we added were prefixed with
'gcc-'?  This seems to go against that.

R.


More information about the Gcc-patches mailing list