# nothing points at this Tree yet! # ...so, we will add a "master" branch repo.refs[b'refs/heads/master'] = commit.id print("Head: {}".format(repo.head().decode('ascii'))) # next, create another commit, changing the contents of our file b2 = Blob.from_string(b"Blobfish are fish, not people\n") t2 = Tree() t2.add(b"a_file.txt", 0o100644, b2.id) c2 = Commit() c2.tree = t2 c2.parents = [commit.id] # note: parents, not parent! c2.author = c2.committer = b"meejah <*****@*****.**>" c2.commit_time = c2.author_time = int(time()) # seconds since epoch c2.commit_timezone = c2.author_timezone = -7 * (60 * 60) # seconds offset; MST c2.encoding = b"utf8" c2.message = b"blobfish are aquatic animals" print(" blob: {}".format(b2.sha().hexdigest())) print(" tree: {}".format(t2.sha().hexdigest())) print("commit: {}".format(c2.sha().hexdigest())) store.add_object(b2) store.add_object(t2) store.add_object(c2) # actually extend master branch repo.refs[b'refs/heads/master'] = c2.id print("Head now: {}".format(repo.refs[b'HEAD'].decode('ascii')))