summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-12-20 18:27:01 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-09 10:00:44 +0100
commit944d82028faed05b3b53e630c9fcf0c4747891e0 (patch)
treed54f45b1cca024f1f3e606e1af0a8293d1a40196
parent379a6f1922aaa9f2eb7ec27a8818fbacd1db0057 (diff)
Replace DOS linefeeds with Unix line feeds when loading a commit message
I have seen some commit messages that contain CRLF instead of just LF; I'm not sure if these were created by a broken git client, but they exist, so we need to deal with them. Editing them when rewording a commit sort of works, but is a little strange; the \r characters are invisble, so you need an extra arrow key press to skip over them. In the next commit we are going to add more logic related to line breaks, and it is getting confused by the \r, so it is becoming more important to fix this. The easiest fix is to normalize the line endings right after loading.
-rw-r--r--pkg/commands/git_commands/commit.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go
index 12806dafc..960fab811 100644
--- a/pkg/commands/git_commands/commit.go
+++ b/pkg/commands/git_commands/commit.go
@@ -142,7 +142,7 @@ func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
ToArgv()
message, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
- return strings.TrimSpace(message), err
+ return strings.ReplaceAll(strings.TrimSpace(message), "\r\n", "\n"), err
}
func (self *CommitCommands) GetCommitSubject(commitSha string) (string, error) {