Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't preview commit with PANIC on gitdiff.go:357 #9173

Closed
2 of 7 tasks
shemgp opened this issue Nov 27, 2019 · 1 comment · Fixed by #9187
Closed
2 of 7 tasks

Can't preview commit with PANIC on gitdiff.go:357 #9173

shemgp opened this issue Nov 27, 2019 · 1 comment · Fixed by #9187
Assignees
Labels
Milestone

Comments

@shemgp
Copy link

shemgp commented Nov 27, 2019

2019/11/27 01:58:26 ...s/charset/charset.go:121:DetectEncoding() [D] Detected encoding: utf-8 (fast)
2019/11/27 01:58:26 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: index out of range [-1]
	/usr/local/go/src/runtime/panic.go:75 (0x435452)
	/go/src/code.gitea.io/gitea/services/gitdiff/gitdiff.go:357 (0x11e9db3)
	/go/src/code.gitea.io/gitea/services/gitdiff/gitdiff.go:865 (0x11eda36)
	/go/src/code.gitea.io/gitea/services/gitdiff/gitdiff.go:809 (0x11ef1ec)
	/go/src/code.gitea.io/gitea/services/gitdiff/gitdiff.go:949 (0x11ef181)
	/go/src/code.gitea.io/gitea/routers/repo/commit.go:229 (0x12d3eed)
	/usr/local/go/src/reflect/value.go:460 (0x497ae5)
	/usr/local/go/src/reflect/value.go:321 (0x4972a3)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9aefa9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9ae959)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x10ce30a)
	/go/src/code.gitea.io/gitea/modules/context/repo.go:751 (0x10ce2f3)
	/usr/local/go/src/reflect/value.go:460 (0x497ae5)
	/usr/local/go/src/reflect/value.go:321 (0x4972a3)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9aefa9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9ae959)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x10ccb4c)
	/go/src/code.gitea.io/gitea/modules/context/repo.go:533 (0x10ccb35)
	/usr/local/go/src/reflect/value.go:460 (0x497ae5)
	/usr/local/go/src/reflect/value.go:321 (0x4972a3)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9aefa9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9ae959)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x10ca4d1)
	/go/src/code.gitea.io/gitea/modules/context/panic.go:39 (0x10ca4bd)
	/usr/local/go/src/reflect/value.go:460 (0x497ae5)
	/usr/local/go/src/reflect/value.go:321 (0x4972a3)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9aefa9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9ae959)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xaac295)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/session/session.go:192 (0xaac280)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:79 (0x9de9a0)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9aecb9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9aea48)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9f0199)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/recovery.go:161 (0x9f0187)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e2673)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9aecb9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9aea48)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9ef4d0)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:52 (0x9ef4bb)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e2673)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9aecb9)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9aea48)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9deaf8)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/router.go:187 (0x9f13b6)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/router.go:303 (0x9ead95)
	/go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/macaron.go:220 (0x9e3a0a)
	/go/src/code.gitea.io/gitea/vendor/github.com/gorilla/context/context.go:141 (0xc4cc8d)
	/usr/local/go/src/net/http/server.go:2007 (0x758973)
	/usr/local/go/src/net/http/server.go:2802 (0x75bdc3)
	/usr/local/go/src/net/http/server.go:1890 (0x757764)
	/usr/local/go/src/runtime/asm_amd64.s:1357 (0x466ec0)

Description

Couldn't view commits with PANIC on services/gitdiff/gitdiff.go:357

Screenshots

Screenshot from 2019-11-27 10-13-28
Screenshot from 2019-11-27 10-13-24

Thanks for looking into this.

@guillep2k
Copy link
Member

It looks like somehow diffFile.Sections is empty @ 357:

// GetTailSection creates a fake DiffLineSection if the last section is not the end of the file
func (diffFile *DiffFile) GetTailSection(gitRepo *git.Repository, leftCommitID, rightCommitID string) *DiffSection {
if diffFile.Type != DiffFileChange || diffFile.IsBin || diffFile.IsLFSFile {
return nil
}
leftCommit, err := gitRepo.GetCommit(leftCommitID)
if err != nil {
return nil
}
rightCommit, err := gitRepo.GetCommit(rightCommitID)
if err != nil {
return nil
}
lastSection := diffFile.Sections[len(diffFile.Sections)-1]
lastLine := lastSection.Lines[len(lastSection.Lines)-1]
leftLineCount := getCommitFileLineCount(leftCommit, diffFile.Name)
rightLineCount := getCommitFileLineCount(rightCommit, diffFile.Name)

@blueworrybear

@lunny lunny added the type/bug label Nov 27, 2019
@lunny lunny added this to the 1.10.1 milestone Nov 27, 2019
@lunny lunny self-assigned this Nov 28, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants