summaryrefslogtreecommitdiffstats
path: root/models/git_diff.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-14 05:07:09 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-06-14 04:07:09 -0500
commit57cabb3ad3d296c2f65c157348cdf3b32e17e8c4 (patch)
tree23747d44f9cff6201ff9027bcebddd60665c2f96 /models/git_diff.go
parent274149dd14909d4ba87f25f8e5160f51ca5f7265 (diff)
downloadgitea-57cabb3ad3d296c2f65c157348cdf3b32e17e8c4.tar.gz
gitea-57cabb3ad3d296c2f65c157348cdf3b32e17e8c4.zip
Fix diff of renamed and modified file (#1967)
Diffstat (limited to 'models/git_diff.go')
-rw-r--r--models/git_diff.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/models/git_diff.go b/models/git_diff.go
index bde2f7ead0..659dfbc0a0 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -365,10 +365,12 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
}
curFile = &DiffFile{
- Name: a,
- Index: len(diff.Files) + 1,
- Type: DiffFileChange,
- Sections: make([]*DiffSection, 0, 10),
+ Name: b,
+ OldName: a,
+ Index: len(diff.Files) + 1,
+ Type: DiffFileChange,
+ Sections: make([]*DiffSection, 0, 10),
+ IsRenamed: a != b,
}
diff.Files = append(diff.Files, curFile)
if len(diff.Files) >= maxFiles {
@@ -401,9 +403,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
curFile.Type = DiffFileChange
case strings.HasPrefix(line, "similarity index 100%"):
curFile.Type = DiffFileRename
- curFile.IsRenamed = true
- curFile.OldName = curFile.Name
- curFile.Name = b
}
if curFile.Type > 0 {
if strings.HasSuffix(line, " 160000\n") {