mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 06:17:55 +01:00
Fix initial commit page & binary munching problem (#13249)
* Fix initial commit page Unfortunately as a result of properly fixing ParsePatch the hack that used git show <initial_commit_id> to get the diff for this failed. This PR fixes this using the "super-secret" empty tree ref to make the diff against. Signed-off-by: Andrew Thornton <art27@cantab.net> * Also fix #13248 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update services/gitdiff/gitdiff.go Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
f6ee7ce9b6
commit
327f18c3b2
@ -530,6 +530,8 @@ parsingLoop:
|
|||||||
break parsingLoop
|
break parsingLoop
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
|
case strings.HasPrefix(line, cmdDiffHead):
|
||||||
|
break curFileLoop
|
||||||
case strings.HasPrefix(line, "old mode ") ||
|
case strings.HasPrefix(line, "old mode ") ||
|
||||||
strings.HasPrefix(line, "new mode "):
|
strings.HasPrefix(line, "new mode "):
|
||||||
if strings.HasSuffix(line, " 160000\n") {
|
if strings.HasSuffix(line, " 160000\n") {
|
||||||
@ -850,7 +852,14 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if (len(beforeCommitID) == 0 || beforeCommitID == git.EmptySHA) && commit.ParentCount() == 0 {
|
if (len(beforeCommitID) == 0 || beforeCommitID == git.EmptySHA) && commit.ParentCount() == 0 {
|
||||||
cmd = exec.CommandContext(ctx, git.GitExecutable, "show", afterCommitID)
|
diffArgs := []string{"diff", "--src-prefix=\\a/", "--dst-prefix=\\b/", "-M"}
|
||||||
|
if len(whitespaceBehavior) != 0 {
|
||||||
|
diffArgs = append(diffArgs, whitespaceBehavior)
|
||||||
|
}
|
||||||
|
// append empty tree ref
|
||||||
|
diffArgs = append(diffArgs, "4b825dc642cb6eb9a060e54bf8d69288fbee4904")
|
||||||
|
diffArgs = append(diffArgs, afterCommitID)
|
||||||
|
cmd = exec.CommandContext(ctx, git.GitExecutable, diffArgs...)
|
||||||
} else {
|
} else {
|
||||||
actualBeforeCommitID := beforeCommitID
|
actualBeforeCommitID := beforeCommitID
|
||||||
if len(actualBeforeCommitID) == 0 {
|
if len(actualBeforeCommitID) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user