summaryrefslogtreecommitdiffstats
path: root/models/git_diff.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-16 07:33:53 -0700
committerUnknwon <u@gogs.io>2016-08-16 07:33:53 -0700
commit9349def72e687c590ed34403f7663c309376610e (patch)
tree67032f7d9e2db00fc244535c9e72fb4a6b550034 /models/git_diff.go
parent6cda35a75f346374121c1ba0ab08adf81dfdcead (diff)
downloadgitea-9349def72e687c590ed34403f7663c309376610e.tar.gz
gitea-9349def72e687c590ed34403f7663c309376610e.zip
#3464 reproduce diff signs
Commited wrong file.
Diffstat (limited to 'models/git_diff.go')
-rw-r--r--models/git_diff.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/models/git_diff.go b/models/git_diff.go
index a63a1bb999..a45c44345b 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -72,6 +72,15 @@ var (
func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTML {
buf := bytes.NewBuffer(nil)
+
+ // Reproduce signs which are cutted for inline diff before.
+ switch lineType {
+ case DIFF_LINE_ADD:
+ buf.WriteByte('+')
+ case DIFF_LINE_DEL:
+ buf.WriteByte('-')
+ }
+
for i := range diffs {
switch {
case diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DIFF_LINE_ADD:
@@ -167,7 +176,7 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem
diff1 = diffLine.Content
diff2 = compareDiffLine.Content
default:
- return template.HTML(html.EscapeString(diffLine.Content[1:]))
+ return template.HTML(html.EscapeString(diffLine.Content))
}
diffRecord := diffMatchPatch.DiffMain(diff1[1:], diff2[1:], true)