summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-20 01:05:32 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-20 13:05:32 +0800
commit75f166b6b9dc51d48b94006e82051c41247605ab (patch)
tree8996c7f20f2d9daff2ea832c6b9548225b1d3065
parent165cf337714769ab79c5fe845f291e56c8243475 (diff)
downloadgitea-75f166b6b9dc51d48b94006e82051c41247605ab.tar.gz
gitea-75f166b6b9dc51d48b94006e82051c41247605ab.zip
Update code.gitea.io/git (#2014)
-rw-r--r--vendor/code.gitea.io/git/tree_entry.go47
-rw-r--r--vendor/vendor.json6
2 files changed, 28 insertions, 25 deletions
diff --git a/vendor/code.gitea.io/git/tree_entry.go b/vendor/code.gitea.io/git/tree_entry.go
index f3b0603456..4c69002f4f 100644
--- a/vendor/code.gitea.io/git/tree_entry.go
+++ b/vendor/code.gitea.io/git/tree_entry.go
@@ -6,8 +6,7 @@ package git
import (
"fmt"
- "os"
- "path/filepath"
+ "path"
"sort"
"strconv"
"strings"
@@ -149,7 +148,7 @@ func (tes Entries) Sort() {
// getCommitInfoState transient state for getting commit info for entries
type getCommitInfoState struct {
entries map[string]*TreeEntry // map from filepath to entry
- commits map[string]*Commit // map from entry name to commit
+ commits map[string]*Commit // map from filepath to commit
lastCommitHash string
lastCommit *Commit
treePath string
@@ -160,7 +159,10 @@ type getCommitInfoState struct {
func initGetCommitInfoState(entries Entries, headCommit *Commit, treePath string) *getCommitInfoState {
entriesByPath := make(map[string]*TreeEntry, len(entries))
for _, entry := range entries {
- entriesByPath[filepath.Join(treePath, entry.Name())] = entry
+ entriesByPath[path.Join(treePath, entry.Name())] = entry
+ }
+ if treePath = path.Clean(treePath); treePath == "." {
+ treePath = ""
}
return &getCommitInfoState{
entries: entriesByPath,
@@ -180,7 +182,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interfac
commitsInfo := make([][]interface{}, len(tes))
for i, entry := range tes {
- commit = state.commits[filepath.Join(treePath, entry.Name())]
+ commit = state.commits[path.Join(treePath, entry.Name())]
switch entry.Type {
case ObjectCommit:
subModuleURL := ""
@@ -211,22 +213,23 @@ func (state *getCommitInfoState) commit() (*Commit, error) {
return state.lastCommit, err
}
-func (state *getCommitInfoState) update(path string) error {
- relPath, err := filepath.Rel(state.treePath, path)
- if err != nil {
- return nil
+func (state *getCommitInfoState) update(entryPath string) error {
+ var entryNameStartIndex int
+ if len(state.treePath) > 0 {
+ entryNameStartIndex = len(state.treePath) + 1
}
- var entryPath string
- if index := strings.IndexRune(relPath, os.PathSeparator); index >= 0 {
- entryPath = filepath.Join(state.treePath, relPath[:index])
- } else {
- entryPath = path
+
+ if index := strings.IndexByte(entryPath[entryNameStartIndex:], '/'); index >= 0 {
+ entryPath = entryPath[:entryNameStartIndex+index]
}
+
if _, ok := state.entries[entryPath]; !ok {
return nil
} else if _, ok := state.commits[entryPath]; ok {
return nil
}
+
+ var err error
state.commits[entryPath], err = state.commit()
return err
}
@@ -251,17 +254,17 @@ func getNextCommitInfos(state *getCommitInfoState) error {
state.nextCommit(lines[i])
i++
for ; i < len(lines); i++ {
- path := lines[i]
- if path == "" {
+ entryPath := lines[i]
+ if entryPath == "" {
break
}
- if path[0] == '"' {
- path, err = strconv.Unquote(path)
+ if entryPath[0] == '"' {
+ entryPath, err = strconv.Unquote(entryPath)
if err != nil {
return fmt.Errorf("Unquote: %v", err)
}
}
- state.update(path)
+ state.update(entryPath)
}
i++ // skip blank line
if len(state.entries) == len(state.commits) {
@@ -284,9 +287,9 @@ func logCommand(exclusiveStartHash string, state *getCommitInfoState) *Command {
searchSize := (numRemainingEntries + 1) / 2
command = NewCommand("log", prettyLogFormat, "--name-only",
"-"+strconv.Itoa(searchSize), commitHash, "--")
- for path, entry := range state.entries {
- if _, ok := state.commits[entry.Name()]; !ok {
- command.AddArguments(path)
+ for entryPath := range state.entries {
+ if _, ok := state.commits[entryPath]; !ok {
+ command.AddArguments(entryPath)
}
}
} else {
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 096cd3ac05..773be8a484 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -3,10 +3,10 @@
"ignore": "test appengine",
"package": [
{
- "checksumSHA1": "LhKqkeygDmm0lohn3T4nna0HC/8=",
+ "checksumSHA1": "Ve00iavGUw8bQmDeXuEJ51wEk40=",
"path": "code.gitea.io/git",
- "revision": "fb22c9ecdb33596b58430368900cc64c9fcdafd8",
- "revisionTime": "2017-06-16T02:13:53Z"
+ "revision": "a34a13dea30c0d242c5256cc321b48f8041ce095",
+ "revisionTime": "2017-06-20T02:08:21Z"
},
{
"checksumSHA1": "nLhT+bLMj8uLICP+EZbrdoQe6mM=",