This change adds `Repository.revert_commit()` which wraps around
`git_revert_commit` which will return an `Index` with the appropriate
changes to revert the specified commit.
Fixes #710
Currently, Index.write_tree() relies on either the caller passing in a
`repo=` arg or the underlying `git_index` being already bound to a
`git_repository`. This ignores the case where the caller does not pass
a `repo` argument to `Index.write_tree()` but the `Index._repo`
property is populated on the index.
This change modifies Index.write_tree() to use the passed-in `repo`
argument, falls back to using `Index._repo` and then assumes that
`git_index` must be bound to a `git_repository`. This change should make
Index.write_tree() a little more robust in the most common use-case.
Instead of using type punning to convert the OID to a Python hash, use
_Py_HashBytes() to hash the OID again. This means we no longer make any
assumptions on the internal representation of OID values or Python
hashes (before this commit, we at least relied on the fact that OID
hases are longer than Python hashes). Moreover, the random seed stored
in PYTHONHASHSEED is now honored.
This also fixes a compiler warning seen with -Wstrict-aliasing.
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
When ffi.new() is used to build a new pointer object, the returned
pointer object has ownership on the allocated memory. When it is
garbage-collected, then the memory is freed. Thus, we need to make sure
the original object survives its use, otherwise the casted pointer will
point to garbage.
This fixes one test which was failing with the latest CFFI version, see
issue #694. Thus, this commit also reverts 803b1cb (cffi 1.10 not yet
supported, 2017-03-22) where the latest CFFI version was marked as
unsupported.
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
Removed a chunk of code from `checkout` that did nothing, but had a bug.
When checking out from a branch-less state (like the state when a repository is first initialized) the code failed.
The failure was due to trying to get some properties of the current branch, which were never used in the code.