From f969cc900dde4ba92c814823bc004bd1870079a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 4 Jan 2019 13:18:54 +0000 Subject: [PATCH] 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. --- index_test.go | 26 +++++++++++++++++++++----- vendor/libgit2 | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/index_test.go b/index_test.go index f47dace..43644fa 100644 --- a/index_test.go +++ b/index_test.go @@ -3,6 +3,7 @@ package git import ( "io/ioutil" "os" + "path" "runtime" "testing" ) @@ -59,14 +60,29 @@ func TestIndexWriteTreeTo(t *testing.T) { repo := createTestRepo(t) defer cleanupTestRepo(t, repo) - repo2 := createTestRepo(t) - defer cleanupTestRepo(t, repo2) + idx, err := NewIndex() + checkFatal(t, err) - idx, err := repo.Index() + odb, err := repo.Odb() checkFatal(t, err) - err = idx.AddByPath("README") + + content, err := ioutil.ReadFile(path.Join(repo.Workdir(), "README")) checkFatal(t, err) - treeId, err := idx.WriteTreeTo(repo2) + + id, err := odb.Write(content, ObjectBlob) + checkFatal(t, err) + + err = idx.Add(&IndexEntry{ + Mode: FilemodeBlob, + Uid: 0, + Gid: 0, + Size: uint32(len(content)), + Id: id, + Path: "README", + }) + checkFatal(t, err) + + treeId, err := idx.WriteTreeTo(repo) checkFatal(t, err) if treeId.String() != "b7119b11e8ef7a1a5a34d3ac87f5b075228ac81e" { diff --git a/vendor/libgit2 b/vendor/libgit2 index 838a2f2..fba70a9 160000 --- a/vendor/libgit2 +++ b/vendor/libgit2 @@ -1 +1 @@ -Subproject commit 838a2f2918b6d9fad8768d2498575ff5d75c35f0 +Subproject commit fba70a9d5f1fa433968a3dfd51e3153c8eebe834