On Tue, 1 Jul 2025, Pierre-Emmanuel Patry wrote:

> Mklog parses the diff content from prepare-commit-msg hook but fails
> when git has been configured with some options (eg. mnemonicPrefix).
> Forcing the default values for the prefixes and the algorithm would
> set a distinct diff configuration supported by mklog and prevent most
> failures.
> 
> contrib/ChangeLog:
> 
>       * prepare-commit-msg: Force default git prefixes and algorithm usage.
> 
> Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>
> ---
>  contrib/prepare-commit-msg | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/contrib/prepare-commit-msg b/contrib/prepare-commit-msg
> index 1b878772dcc..fc4c4d80b16 100755
> --- a/contrib/prepare-commit-msg
> +++ b/contrib/prepare-commit-msg
> @@ -78,4 +78,8 @@ else
>      tee="cat"
>  fi
>  
> -git $cmd | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"
> +# Provides a baseline for everyone, we only need to deal with the default
> +# values within mklog.
> +default_values="--diff-algorithm=default --default-prefix"

Is switching the algorithm actually necessary for solving the problem at hand?
I think it is possible for the default algorithm to produce diffs that lead to
poorly generated changelog entries, so forcing it here seems undesirable.

If just --default-prefix is enough, I think you can just add it to the below
line and commit/push.

> +
> +git $cmd $default_values | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"

Alexander

Reply via email to