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 --- modules/repository/init.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'modules/repository/init.go') diff --git a/modules/repository/init.go b/modules/repository/init.go index 5705fe5b99..771b68a491 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -316,9 +316,8 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi return fmt.Errorf("git add --all: %w", err) } - cmd := git.NewCommand(ctx, "commit"). - AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). - AddOptionValues("-m", "Initial commit") + cmd := git.NewCommand(ctx, "commit", "--message=Initial commit"). + AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email) sign, keyID, signer, _ := asymkey_service.SignInitialCommit(ctx, tmpPath, u) if sign { -- cgit v1.2.3