Commit Graph

6 Commits

Author SHA1 Message Date
Jonathan Wakely
df665e568d contrib: Make prepare-commit-msg hook smarter for amends
With this change the prepare-commit-msg hook can compare the log of a
commit being amended with the staged changes, and not run mklog.py
unnecessarily. This is controlled by a git config option,
gcc-config.mklog-hook-type.

contrib/ChangeLog:

	* prepare-commit-msg: Use the gcc-config.mklog-hook-type Git
	config key instead of the GCC_FORCE_MKLOG environment variable.
	Optionally disable generating a new ChangeLog template for
	amended commits when the existing log is still OK.
2020-06-11 20:22:33 +01:00
Martin Liska
8ff57396d6
prepare-commit-hook: Use gcc-config.diff-file.
contrib/ChangeLog:

	* prepare-commit-msg: Replace ENV variable with a git config
	value.
2020-06-11 10:09:47 +02:00
Jonathan Wakely
9aadfdd650
contrib: Avoid redundant 'git diff' in prepare-commit-msg hook
contrib/ChangeLog:

	* prepare-commit-msg: Use 'tee' to save the diff to a file
	instead of running 'git diff' twice.
2020-06-11 09:57:58 +02:00
Jonathan Wakely
9127b52398 contrib: Make prepare-commit-msg hook safe for older branches
If a user installs this script as .git/hooks/prepare-commit-msg and then
works on an old branch which doesn't have the mklog.py script, trying to
commit will fail with an error like:

environment: /.../gcc/contrib/mklog.py: No such file or directory

This makes it exit cleanly so it's possible to commit.

contrib/ChangeLog:

	* prepare-commit-msg: Do nothing if the mklog.py script isn't
	present.
2020-06-02 11:18:21 +01:00
Martin Liska
7b8ee33aff
prepare-commit-msg: Save diff if requested by user.
contrib/ChangeLog:

	* prepare-commit-msg: Save diff to a file if
	the GCC_GIT_DIFF_FILE variable is set.
2020-05-27 10:12:58 +02:00
Jason Merrill
757dbb59c1
gcc-git: Add prepare-commit-msg hook.
This patch introduces a prepare-commit-msg hook that appends a ChangeLog
skeleton to a commit message when the GCC_FORCE_MKLOG environment variable
is set, and a 'git commit-mklog' command set that variable while running
'git commit'.

contrib/ChangeLog:

	* prepare-commit-msg: New file.
	* gcc-git-customization.sh: Install it.  Add commit-mklog alias.
	* mklog.py: Add new option -c which appends
	to a ChangeLog file.
2020-05-26 08:38:24 +02:00