On Fri, 22 Jul 2022 at 10:38, Martin Liška wrote:
>
> Hi.
>
> Motivation example:
> $ git commit-mklog -a -b 'PR other/106370,PR other/12345'
>
> Preserving a space from git gcc-mklog hook to contrib/mklog.py seems
> pretty challenging. Thus I recommend preserving extra mklog args via
> env where it's encoded in JSON format.
>
> Thoughts?

This solution looks much better than trying to get the shell quoting
and word splitting right.

For the record, my suggestion was to surround each arg in double
quotes within the env var and then ...

> diff --git a/contrib/prepare-commit-msg b/contrib/prepare-commit-msg
> index 5da878458cd..969847df6f4 100755
> --- a/contrib/prepare-commit-msg
> +++ b/contrib/prepare-commit-msg
> @@ -78,4 +78,4 @@ else
>      tee="cat"
>  fi
>
> -git $cmd | $tee | git gcc-mklog $GCC_MKLOG_ARGS -c "$COMMIT_MSG_FILE"
> +git $cmd | $tee | git gcc-mklog -c "$COMMIT_MSG_FILE"

... change this to:

mklog() {
  echo "$GCC_MKLOG_ARGS" | xargs -x git gcc-mklog -c "$COMMIT_MSG_FILE"
}
git $cmd | $tee | mklog

This works because xargs respects quotes within its input and so would
pass them correctly to the git gcc-mklog command.

But avoiding this entirely by storing them as json and then not
retrieving them until the mklog.py step is more reliable.

Reply via email to