diff --git a/modules/git/commit.go b/modules/git/commit.go index 32589f5349..810c9a9e31 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -455,17 +455,18 @@ func NewCommitFileStatus() *CommitFileStatus { func parseCommitFileStatus(fileStatus *CommitFileStatus, stdout io.Reader) { rd := bufio.NewReader(stdout) - peek, err := rd.Peek(1) - if err != nil { - if err != io.EOF { - log.Error("Unexpected error whilst reading from git log --name-status. Error: %v", err) - } - return - } - if peek[0] == '\n' || peek[0] == '\x00' { - _, _ = rd.Discard(1) - } for { + // In case of merge commits, Git will add a separator between each + peek, err := rd.Peek(1) + if err != nil { + if err != io.EOF { + log.Error("Unexpected error whilst reading from git log --name-status. Error: %v", err) + } + return + } + if peek[0] == '\n' || peek[0] == '\x00' { + _, _ = rd.Discard(1) + } modifier, err := rd.ReadSlice('\x00') if err != nil { if err != io.EOF { @@ -503,7 +504,7 @@ func GetCommitFileStatus(ctx context.Context, repoPath, commitID string) (*Commi }() stderr := new(bytes.Buffer) - args := []string{"log", "--name-status", "-c", "--pretty=format:", "--parents", "--no-renames", "-z", "-1", commitID} + args := []string{"log", "--name-status", "-m", "--pretty=format:", "--parents", "--no-renames", "-z", "-1", commitID} err := NewCommand(ctx, args...).Run(&RunOpts{ Dir: repoPath,