-
Notifications
You must be signed in to change notification settings - Fork 812
Closed
Description
func TestAA(t *testing.T) {
abs, _ := filepath.Abs("F:\\workspace\\github\\go-git")
repo, err := git.PlainOpen(abs)
if err != nil {
panic(err)
}
head, err := repo.Head()
if err != nil {
panic(err)
}
targetCommit, err := repo.CommitObject(head.Hash())
if err != nil {
panic(err)
}
_, err = git.Blame(targetCommit, "remote.go")
if err != nil {
// PANIC!!!
panic(err)
}
}
panic happened when calling git.Blame
panic: contents and commits have different length [recovered]
panic: contents and commits have different length
It will happened also in work_tree_test.go
.
Looks like it can not handle extra empty line at the end of file.
In git blame:
But actually:
Tested on Windows and WSL.
guess
func newLines(contents []string, commits []*object.Commit) ([]*Line, error) {
lcontents := len(contents)
lcommits := len(commits)
if lcontents != lcommits {
fmt.Printf("c vs c: %d, %d", lcontents, lcommits)
...
Output:
=== RUN TestAA
c vs c: 1430, 1397--- FAIL: TestAA (1.97s)
lcommits seems not correct.
Metadata
Metadata
Assignees
Labels
No labels