public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Emacs ChangeLog generation and commit messages
@ 2023-11-06 16:38 Florian Weimer
  2023-11-06 16:41 ` Jakub Jelinek
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Florian Weimer @ 2023-11-06 16:38 UTC (permalink / raw)
  To: gcc

Emacs has a very useful facility.  You press “C-x 4 a” in a place where
you make changes, and the editor automatically opens the right ChangeLog
file and adds a draft entry to it, like this:

2023-11-06  Florian Weimer  <fweimer@redhat.com>

	* c-opts.cc (c_common_post_options): █

Is there something like this that works with commit messages and
produces output compatible with GCC's expectations?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs ChangeLog generation and commit messages
  2023-11-06 16:38 Emacs ChangeLog generation and commit messages Florian Weimer
@ 2023-11-06 16:41 ` Jakub Jelinek
  2023-11-06 16:42 ` Andrew Pinski
  2023-11-06 17:45 ` Martin Jambor
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2023-11-06 16:41 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc

On Mon, Nov 06, 2023 at 05:38:40PM +0100, Florian Weimer via Gcc wrote:
> Emacs has a very useful facility.  You press “C-x 4 a” in a place where
> you make changes, and the editor automatically opens the right ChangeLog
> file and adds a draft entry to it, like this:
> 
> 2023-11-06  Florian Weimer  <fweimer@redhat.com>
> 
> 	* c-opts.cc (c_common_post_options): █
> 
> Is there something like this that works with commit messages and
> produces output compatible with GCC's expectations?

contrib/mklog.py ?

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs ChangeLog generation and commit messages
  2023-11-06 16:38 Emacs ChangeLog generation and commit messages Florian Weimer
  2023-11-06 16:41 ` Jakub Jelinek
@ 2023-11-06 16:42 ` Andrew Pinski
  2023-11-06 17:45 ` Martin Jambor
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Pinski @ 2023-11-06 16:42 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc

On Mon, Nov 6, 2023 at 8:39 AM Florian Weimer via Gcc <gcc@gcc.gnu.org> wrote:
>
> Emacs has a very useful facility.  You press “C-x 4 a” in a place where
> you make changes, and the editor automatically opens the right ChangeLog
> file and adds a draft entry to it, like this:
>
> 2023-11-06  Florian Weimer  <fweimer@redhat.com>
>
>         * c-opts.cc (c_common_post_options): █
>
> Is there something like this that works with commit messages and
> produces output compatible with GCC's expectations?

Yes contrib/git-commit-mklog.py .
Which can also be used directly with git if you run
`contrib/gcc-git-customization.sh`. This will install an alias so you
can just do `git gcc-commit-mklog ....` and you will get a commit log
with that part filled in.

Thanks,
Andrew

>
> Thanks,
> Florian
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Emacs ChangeLog generation and commit messages
  2023-11-06 16:38 Emacs ChangeLog generation and commit messages Florian Weimer
  2023-11-06 16:41 ` Jakub Jelinek
  2023-11-06 16:42 ` Andrew Pinski
@ 2023-11-06 17:45 ` Martin Jambor
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Jambor @ 2023-11-06 17:45 UTC (permalink / raw)
  To: Florian Weimer, gcc

Hello,

On Mon, Nov 06 2023, Florian Weimer via Gcc wrote:
> Emacs has a very useful facility.  You press “C-x 4 a” in a place where
> you make changes, and the editor automatically opens the right ChangeLog
> file and adds a draft entry to it, like this:
>
> 2023-11-06  Florian Weimer  <fweimer@redhat.com>
>
> 	* c-opts.cc (c_common_post_options): █
>
> Is there something like this that works with commit messages and
> produces output compatible with GCC's expectations?
>

I use exactly this.  But I modify it to write the ChangeLog to file
ChangeLog.mine instead:

  (setq change-log-default-name "ChangeLog.mine")

Then in a git prepare-commit-msg hook I gather these:

----------------------------------------------------------------------
#!/bin/bash
#
# Hook script to prepare the commit log message from the first
# entry in each modified ChangeLog being committed.

set -e

# echo $1 $2 $3

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

# "merge" means the commit is a merge or a .git/MERGE_MSG file exists.
# "message" means a -m or -F option was given.
# "squash" means a .git/SQUASH_MSG file exists.
# "commit" means a -c, -C or --amend option was given (and $3 is commit SHA1).
case "$2," in
  merge,|squash,) exit ;;
  message,) exit ;;
esac

# If there is already a ChangeLog entry, assume --amend and exit
grep -q "ChangeLog" "$COMMIT_MSG_FILE" && exit 0

TMPF=$(mktemp)

echo > $TMPF 

for I in `find . -name ChangeLog.mine -type f -size +0c | xargs`; do
    echo >> $TMPF 
    CNF=`echo ${I%.mine} | cut -c3-` >> $TMPF 
    echo "${CNF}:" >> $TMPF 
    echo >> $TMPF 
    awk -v n=2 '/^2/{p++} p<n' $I >> $TMPF 
done

echo >> $TMPF 
cat $COMMIT_MSG_FILE >> $TMPF

mv $TMPF $COMMIT_MSG_FILE
----------------------------------------------------------------------

The only downside is that you need to truncate the ChangeLog.mine files
at the appropriate time.  The big upside is that you can generate
ChangeLog as you stage hunks in emacs magit.

Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-06 17:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 16:38 Emacs ChangeLog generation and commit messages Florian Weimer
2023-11-06 16:41 ` Jakub Jelinek
2023-11-06 16:42 ` Andrew Pinski
2023-11-06 17:45 ` Martin Jambor

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 read-only IMAP folder(s) and NNTP newsgroup(s).