The new function does a little more, saving some lines from the callers.
This change will allow to implement a cache, now all object lookups are
centralized in a single function.
Do not allow to create commits, trees, blobs and tags directly from the
constructor. For instance, now calling "Commit(...)" raises an error.
Instead use the create methods of the repository object:
Before Now
----------------------------- -----------------------------
commit = Commit(repo, ...) sha = repo.create_commit(...)
tag = Tag(repo, ...) sha = repo.create_tag(...)
Most often you won't need to get the object just created, but if you
do just call "repo[sha]" afterwards. (Methods to create blobs and trees
are still missing, just like before.)
Similarly the method that creates a tree object from the index file does
not return the tree object anymore, but just its SHA:
Before Now
----------------------------- -----------------------------
tree = index.create_tree() sha = index.create_tree()
Tree entries are not Git objects like commits, blobs, etc.
By inheriting from Object it was even possible to produce a segfault
when accessing inherited attributes like 'type'.
Now it is possible to pass None as the commit hash to get a non
initialized walker. A second and optional parameter allows to set
the sorting mode.
Signed-off-by: J. David Ibañez <jdavid@itaapy.com>
It is possible to:
len(index) # get the number of entries in the index
'...' in index # check whether there is an entry with the given path
index[1] # get entry by position
index['...'] # get entry by path
del index[...] # remove entry by position or path
-Factor out a function for mapping libgit2 error numbers to Python
exception types.
-Rename Error_set_py_str -> Error_set_py_obj.
-Simplify formatting of Error_set_py_obj to just prefix the git_strerror
with the offending object.
-Add Error_set_str, like py_str but with C strings.
Change-Id: I51fe47c96a0c57aaeafd2c98418c0c548b93147d
This also gives us more flexibility if we decide to change the person
object representation to something other than a tuple.
Also fix a format string to correctly cast to long long.
Change-Id: I0ed496c6807328084a26a956c77871c3cb76eedf