4
Remember you learned that the file name and content are distinct. So renaming
5
a file is just about associating a blob id to a new name. We won't store more
6
content, and the operation will be painless.
8
Let's transfer the blob id from the old name to the new one::
10
>>> tree["eggs"] = tree["spam"]
13
As usual, we need a commit to store the new tree id::
17
>>> c5.parents = [commit.id]
18
>>> c5.author = c5.committer = author
19
>>> c5.commit_time = c5.author_time = int(time())
20
>>> c5.commit_timezone = c5.author_timezone = tz
21
>>> c5.encoding = "UTF-8"
22
>>> c5.message = 'Rename "spam" to "eggs"'
24
As for a deletion, we only have a tree and a commit to save::
26
>>> object_store.add_object(tree)
27
>>> object_store.add_object(c5)
29
Remains to make the head bleeding-edge::
31
>>> repo.refs['refs/heads/master'] = commit.id
33
As a last exercise, see how ``git show`` illustrates it.