aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-01 03:34:46 +0800
committerzeripath <art27@cantab.net>2019-05-31 20:34:46 +0100
commit8a343dda39b187627db6ffb4c24a6e0ae615867b (patch)
treec72f6c3d7ec007f5c085ca343116e7683c3f8693 /vendor/gopkg.in
parentfb4438a815b013895f3171f8f2f1ed22f79596de (diff)
downloadgitea-8a343dda39b187627db6ffb4c24a6e0ae615867b.tar.gz
gitea-8a343dda39b187627db6ffb4c24a6e0ae615867b.zip
update go git from v4.10.0 to v4.11.0 (#7096)
Diffstat (limited to 'vendor/gopkg.in')
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/.travis.yml2
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/options.go4
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/object_lru.go5
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit.go38
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit_walker_bfs.go2
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/plumbing/object/patch.go11
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/plumbing/object/tree.go2
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/remote.go9
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/repository.go17
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go18
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/worktree.go11
-rw-r--r--vendor/gopkg.in/src-d/go-git.v4/worktree_status.go6
12 files changed, 89 insertions, 36 deletions
diff --git a/vendor/gopkg.in/src-d/go-git.v4/.travis.yml b/vendor/gopkg.in/src-d/go-git.v4/.travis.yml
index c68b5f473e..3a65f3e082 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/.travis.yml
+++ b/vendor/gopkg.in/src-d/go-git.v4/.travis.yml
@@ -1,8 +1,8 @@
language: go
go:
- - "1.10"
- "1.11"
+ - "1.12"
go_import_path: gopkg.in/src-d/go-git.v4
diff --git a/vendor/gopkg.in/src-d/go-git.v4/options.go b/vendor/gopkg.in/src-d/go-git.v4/options.go
index ed7689ab3f..7c9e687288 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/options.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/options.go
@@ -229,7 +229,7 @@ var (
ErrCreateRequiresBranch = errors.New("Branch is mandatory when Create is used")
)
-// CheckoutOptions describes how a checkout 31operation should be performed.
+// CheckoutOptions describes how a checkout operation should be performed.
type CheckoutOptions struct {
// Hash is the hash of the commit to be checked out. If used, HEAD will be
// in detached mode. If Create is not used, Branch and Hash are mutually
@@ -288,7 +288,7 @@ const (
// ResetOptions describes how a reset operation should be performed.
type ResetOptions struct {
- // Commit, if commit is pressent set the current branch head (HEAD) to it.
+ // Commit, if commit is present set the current branch head (HEAD) to it.
Commit plumbing.Hash
// Mode, form resets the current branch head to Commit and possibly updates
// the index (resetting it to the tree of Commit) and the working tree
diff --git a/vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/object_lru.go b/vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/object_lru.go
index 53d8b02d96..cd3712b7d7 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/object_lru.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/plumbing/cache/object_lru.go
@@ -61,6 +61,11 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) {
c.actualSize += objSize
for c.actualSize > c.MaxSize {
last := c.ll.Back()
+ if last == nil {
+ c.actualSize = 0
+ break
+ }
+
lastObj := last.Value.(plumbing.EncodedObject)
lastSize := FileSize(lastObj.Size())
diff --git a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit.go b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit.go
index e2543426ac..b569d3ce2d 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit.go
@@ -76,8 +76,8 @@ func (c *Commit) Tree() (*Tree, error) {
return GetTree(c.s, c.TreeHash)
}
-// Patch returns the Patch between the actual commit and the provided one.
-// Error will be return if context expires. Provided context must be non-nil
+// PatchContext returns the Patch between the actual commit and the provided one.
+// Error will be return if context expires. Provided context must be non-nil.
func (c *Commit) PatchContext(ctx context.Context, to *Commit) (*Patch, error) {
fromTree, err := c.Tree()
if err != nil {
@@ -291,25 +291,33 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
return err
}
-// Stats shows the status of commit.
+// Stats returns the stats of a commit.
func (c *Commit) Stats() (FileStats, error) {
- // Get the previous commit.
- ci := c.Parents()
- parentCommit, err := ci.Next()
+ return c.StatsContext(context.Background())
+}
+
+// StatsContext returns the stats of a commit. Error will be return if context
+// expires. Provided context must be non-nil.
+func (c *Commit) StatsContext(ctx context.Context) (FileStats, error) {
+ fromTree, err := c.Tree()
if err != nil {
- if err == io.EOF {
- emptyNoder := treeNoder{}
- parentCommit = &Commit{
- Hash: emptyNoder.hash,
- // TreeHash: emptyNoder.parent.Hash,
- s: c.s,
- }
- } else {
+ return nil, err
+ }
+
+ toTree := &Tree{}
+ if c.NumParents() != 0 {
+ firstParent, err := c.Parents().Next()
+ if err != nil {
+ return nil, err
+ }
+
+ toTree, err = firstParent.Tree()
+ if err != nil {
return nil, err
}
}
- patch, err := parentCommit.Patch(c)
+ patch, err := toTree.PatchContext(ctx, fromTree)
if err != nil {
return nil, err
}
diff --git a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit_walker_bfs.go b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit_walker_bfs.go
index aef1cf24c6..dabfe75c27 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit_walker_bfs.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/commit_walker_bfs.go
@@ -67,7 +67,7 @@ func (w *bfsCommitIterator) Next() (*Commit, error) {
for _, h := range c.ParentHashes {
err := w.appendHash(c.s, h)
if err != nil {
- return nil, nil
+ return nil, err
}
}
diff --git a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/patch.go b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/patch.go
index adeaccb0a8..068589eff8 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/patch.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/patch.go
@@ -320,11 +320,18 @@ func getFileStatsFromFilePatches(filePatches []fdiff.FilePatch) FileStats {
}
for _, chunk := range fp.Chunks() {
+ s := chunk.Content()
switch chunk.Type() {
case fdiff.Add:
- cs.Addition += strings.Count(chunk.Content(), "\n")
+ cs.Addition += strings.Count(s, "\n")
+ if s[len(s)-1] != '\n' {
+ cs.Addition++
+ }
case fdiff.Delete:
- cs.Deletion += strings.Count(chunk.Content(), "\n")
+ cs.Deletion += strings.Count(s, "\n")
+ if s[len(s)-1] != '\n' {
+ cs.Deletion++
+ }
}
}
diff --git a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/tree.go b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/tree.go
index 78d61a1fba..1f9ea2651c 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/tree.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/plumbing/object/tree.go
@@ -135,7 +135,7 @@ func (t *Tree) FindEntry(path string) (*TreeEntry, error) {
pathCurrent := ""
// search for the longest path in the tree path cache
- for i := len(pathParts); i > 1; i-- {
+ for i := len(pathParts) - 1; i > 1; i-- {
path := filepath.Join(pathParts[:i]...)
tree, ok := t.t[path]
diff --git a/vendor/gopkg.in/src-d/go-git.v4/remote.go b/vendor/gopkg.in/src-d/go-git.v4/remote.go
index de537ce8e8..80604092ab 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/remote.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/remote.go
@@ -1020,7 +1020,12 @@ func pushHashes(
if err != nil {
return nil, err
}
- done := make(chan error)
+
+ // Set buffer size to 1 so the error message can be written when
+ // ReceivePack fails. Otherwise the goroutine will be blocked writing
+ // to the channel.
+ done := make(chan error, 1)
+
go func() {
e := packfile.NewEncoder(wr, s, useRefDeltas)
if _, err := e.Encode(hs, config.Pack.Window); err != nil {
@@ -1033,6 +1038,8 @@ func pushHashes(
rs, err := sess.ReceivePack(ctx, req)
if err != nil {
+ // close the pipe to unlock encode write
+ _ = rd.Close()
return nil, err
}
diff --git a/vendor/gopkg.in/src-d/go-git.v4/repository.go b/vendor/gopkg.in/src-d/go-git.v4/repository.go
index de92d64709..e5b12b0c52 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/repository.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/repository.go
@@ -49,6 +49,7 @@ var (
ErrRepositoryAlreadyExists = errors.New("repository already exists")
ErrRemoteNotFound = errors.New("remote not found")
ErrRemoteExists = errors.New("remote already exists")
+ ErrAnonymousRemoteName = errors.New("anonymous remote name must be 'anonymous'")
ErrWorktreeNotProvided = errors.New("worktree should be provided")
ErrIsBareRepository = errors.New("worktree not available in a bare repository")
ErrUnableToResolveCommit = errors.New("unable to resolve commit")
@@ -492,6 +493,22 @@ func (r *Repository) CreateRemote(c *config.RemoteConfig) (*Remote, error) {
return remote, r.Storer.SetConfig(cfg)
}
+// CreateRemoteAnonymous creates a new anonymous remote. c.Name must be "anonymous".
+// It's used like 'git fetch git@github.com:src-d/go-git.git master:master'.
+func (r *Repository) CreateRemoteAnonymous(c *config.RemoteConfig) (*Remote, error) {
+ if err := c.Validate(); err != nil {
+ return nil, err
+ }
+
+ if c.Name != "anonymous" {
+ return nil, ErrAnonymousRemoteName
+ }
+
+ remote := newRemote(r.Storer, c)
+
+ return remote, nil
+}
+
// DeleteRemote delete a remote from the repository and delete the config
func (r *Repository) DeleteRemote(name string) error {
cfg, err := r.Storer.Config()
diff --git a/vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go b/vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go
index f49ae55bae..6142ed0515 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/utils/diff/diff.go
@@ -8,14 +8,30 @@ package diff
import (
"bytes"
+ "time"
"github.com/sergi/go-diff/diffmatchpatch"
)
// Do computes the (line oriented) modifications needed to turn the src
-// string into the dst string.
+// string into the dst string. The underlying algorithm is Meyers,
+// its complexity is O(N*d) where N is min(lines(src), lines(dst)) and d
+// is the size of the diff.
func Do(src, dst string) (diffs []diffmatchpatch.Diff) {
+ // the default timeout is time.Second which may be too small under heavy load
+ return DoWithTimeout(src, dst, time.Hour)
+}
+
+// DoWithTimeout computes the (line oriented) modifications needed to turn the src
+// string into the dst string. The `timeout` argument specifies the maximum
+// amount of time it is allowed to spend in this function. If the timeout
+// is exceeded, the parts of the strings which were not considered are turned into
+// a bulk delete+insert and the half-baked suboptimal result is returned at once.
+// The underlying algorithm is Meyers, its complexity is O(N*d) where N is
+// min(lines(src), lines(dst)) and d is the size of the diff.
+func DoWithTimeout (src, dst string, timeout time.Duration) (diffs []diffmatchpatch.Diff) {
dmp := diffmatchpatch.New()
+ dmp.DiffTimeout = timeout
wSrc, wDst, warray := dmp.DiffLinesToRunes(src, dst)
diffs = dmp.DiffMainRunes(wSrc, wDst, false)
diffs = dmp.DiffCharsToLines(diffs, warray)
diff --git a/vendor/gopkg.in/src-d/go-git.v4/worktree.go b/vendor/gopkg.in/src-d/go-git.v4/worktree.go
index a14fd8d6c3..dae40a38a7 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/worktree.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/worktree.go
@@ -152,17 +152,6 @@ func (w *Worktree) Checkout(opts *CheckoutOptions) error {
}
}
- if !opts.Force {
- unstaged, err := w.containsUnstagedChanges()
- if err != nil {
- return err
- }
-
- if unstaged {
- return ErrUnstagedChanges
- }
- }
-
c, err := w.getCommitFromCheckoutOptions(opts)
if err != nil {
return err
diff --git a/vendor/gopkg.in/src-d/go-git.v4/worktree_status.go b/vendor/gopkg.in/src-d/go-git.v4/worktree_status.go
index 0e113d0937..16ce937077 100644
--- a/vendor/gopkg.in/src-d/go-git.v4/worktree_status.go
+++ b/vendor/gopkg.in/src-d/go-git.v4/worktree_status.go
@@ -142,12 +142,16 @@ func (w *Worktree) diffStagingWithWorktree(reverse bool) (merkletrie.Changes, er
func (w *Worktree) excludeIgnoredChanges(changes merkletrie.Changes) merkletrie.Changes {
patterns, err := gitignore.ReadPatterns(w.Filesystem, nil)
- if err != nil || len(patterns) == 0 {
+ if err != nil {
return changes
}
patterns = append(patterns, w.Excludes...)
+ if len(patterns) == 0 {
+ return changes
+ }
+
m := gitignore.NewMatcher(patterns)
var res merkletrie.Changes