-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Use commit graph files for listing pages #7314
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
Changes from all commits
4044b96
ec1753d
439af65
6635ebe
33c2254
2f153fa
9de6e24
4a7cc0d
a9b7776
0ca28c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019 The Gitea Authors. | ||
// All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package git | ||
|
||
import ( | ||
"os" | ||
"path" | ||
|
||
gitealog "code.gitea.io/gitea/modules/log" | ||
"gopkg.in/src-d/go-git.v4/plumbing/format/commitgraph" | ||
cgobject "gopkg.in/src-d/go-git.v4/plumbing/object/commitgraph" | ||
) | ||
|
||
// CommitNodeIndex returns the index for walking commit graph | ||
func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) { | ||
indexPath := path.Join(r.Path, "objects", "info", "commit-graph") | ||
|
||
file, err := os.Open(indexPath) | ||
if err == nil { | ||
var index commitgraph.Index | ||
index, err = commitgraph.OpenFileIndex(file) | ||
if err == nil { | ||
return cgobject.NewGraphCommitNodeIndex(index, r.gogitRepo.Storer), file | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If err is not file not exist error, we should return it but not hide it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should return it. This is quite graceful error handling with fallback to the regular git object storage. Worst case is a performance penalty but it will still yield the same results. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. But at least, we should know commit graph is not using since something wrong. We need an error log or warning log if commitgraph file exist but load failed. That will be helpful when we investigate errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lunny is my change to lines 30-33 acceptable? |
||
if !os.IsNotExist(err) { | ||
gitealog.Warn("Unable to read commit-graph for %s: %v", r.Path, err) | ||
} | ||
|
||
return cgobject.NewObjectCommitNodeIndex(r.gogitRepo.Storer), nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.