New mklog script

Jason Merrill jason@redhat.com
Fri May 22 21:01:02 GMT 2020


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:

#!/bin/sh

#COMMIT_MSG_FILE=$1
#COMMIT_SOURCE=$2
#SHA1=$3

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



More information about the Gcc mailing list