Update TreeEntry multiple levels deep in pygit2

110 views Asked by At

Having trouble figuring out how to update an entry which is multiple levels deep. My example below is trying to update the file at test/hist/out, but it also deletes all other files from test/hist/.

The TreeBuilder constructor doesnt accept TreeEntries, only Trees, so I'm not sure how to go about it. Any idea?

_o = repo.TreeBuilder()
_o.insert('out', blob_id, pygit2.GIT_FILEMODE_BLOB)
_o = _o.write()

_h = repo.TreeBuilder()
_h.insert('hist', _o, pygit2.GIT_FILEMODE_TREE)
_h = _h.write()

_t = repo.TreeBuilder(tree)
_t.insert('test', _h, pygit2.GIT_FILEMODE_TREE)
_t = _t.write()
1

There are 1 answers

1
Scott On

Figured it out, the answer is to pass tree['path/to/your/subfolder'].oid in the construction of your TreeBuilders. Yay!