summaryrefslogtreecommitdiffstats
path: root/pkg/commands/patch/patch_parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/patch/patch_parser.go')
-rw-r--r--pkg/commands/patch/patch_parser.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index 1fd3c107a..3f191f40a 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -134,7 +134,8 @@ func coloredString(textStyle style.TextStyle, str string, selected bool, include
}
func parsePatch(patch string) ([]int, []int, []*PatchLine) {
- lines := strings.Split(patch, "\n")
+ // ignore trailing newline.
+ lines := strings.Split(strings.TrimSuffix(patch, "\n"), "\n")
hunkStarts := []int{}
stageableLines := []int{}
pastFirstHunkHeader := false
@@ -179,6 +180,7 @@ func parsePatch(patch string) ([]int, []int, []*PatchLine) {
}
patchLines[index] = &PatchLine{Kind: lineKind, Content: line}
}
+
return hunkStarts, stageableLines, patchLines
}