From dc9cebdf45d3594058727a5c8a5f20af098c5e7a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 21 Feb 2023 14:12:57 +0800 Subject: Use `--message=%s` for git commit message (#23028) Close #23027 `git commit` message option _only_ supports 4 formats (well, only ....): * `"commit", "-m", msg` * `"commit", "-m{msg}"` (no space) * `"commit", "--message", msg` * `"commit", "--message={msg}"` The long format with `=` is the best choice, and it's documented in `man git-commit`: `-m , --message= ...` ps: I would suggest always use long format option for git command, as much as possible. Co-authored-by: Lunny Xiao --- services/pull/merge.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/pull/merge.go b/services/pull/merge.go index 3ac67d91b7..ad428427cc 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -533,7 +533,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode if err := git.NewCommand(ctx, "commit"). AddArguments(signArgs...). AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). - AddOptionValues("-m", message). + AddOptionFormat("--message=%s", message). Run(&git.RunOpts{ Env: env, Dir: tmpBasePath, @@ -641,7 +641,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode func commitAndSignNoAuthor(ctx context.Context, pr *issues_model.PullRequest, message string, signArgs git.TrustedCmdArgs, tmpBasePath string, env []string) error { var outbuf, errbuf strings.Builder - if err := git.NewCommand(ctx, "commit").AddArguments(signArgs...).AddOptionValues("-m", message). + if err := git.NewCommand(ctx, "commit").AddArguments(signArgs...).AddOptionFormat("--message=%s", message). Run(&git.RunOpts{ Env: env, Dir: tmpBasePath, -- cgit v1.2.3