Skip to content

Commit f969cc9

Browse files
committed
Bump vendored libgit2 to fba70a9d5f
This includes updating the `Index.WriteTreeTo` test as it was abusing an oversight of the object creation safety checks and creating a tree referencing a non-existent blob. Instead we update it to the primary purpose of this method which is to write into a repository from an unattached index.
1 parent bcf3252 commit f969cc9

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

index_test.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package git
33
import (
44
"io/ioutil"
55
"os"
6+
"path"
67
"runtime"
78
"testing"
89
)
@@ -59,14 +60,29 @@ func TestIndexWriteTreeTo(t *testing.T) {
5960
repo := createTestRepo(t)
6061
defer cleanupTestRepo(t, repo)
6162

62-
repo2 := createTestRepo(t)
63-
defer cleanupTestRepo(t, repo2)
63+
idx, err := NewIndex()
64+
checkFatal(t, err)
6465

65-
idx, err := repo.Index()
66+
odb, err := repo.Odb()
6667
checkFatal(t, err)
67-
err = idx.AddByPath("README")
68+
69+
content, err := ioutil.ReadFile(path.Join(repo.Workdir(), "README"))
70+
checkFatal(t, err)
71+
72+
id, err := odb.Write(content, ObjectBlob)
6873
checkFatal(t, err)
69-
treeId, err := idx.WriteTreeTo(repo2)
74+
75+
err = idx.Add(&IndexEntry{
76+
Mode: FilemodeBlob,
77+
Uid: 0,
78+
Gid: 0,
79+
Size: uint32(len(content)),
80+
Id: id,
81+
Path: "README",
82+
})
83+
checkFatal(t, err)
84+
85+
treeId, err := idx.WriteTreeTo(repo)
7086
checkFatal(t, err)
7187

7288
if treeId.String() != "b7119b11e8ef7a1a5a34d3ac87f5b075228ac81e" {

vendor/libgit2

Submodule libgit2 updated 7942 files

0 commit comments

Comments
 (0)