This commit allows blobs to be constructed from implementatons of the
'RawIOBase' ABC. This allows any conformant stream implementation to be added
as a blob.
This is useful in the case where the contents of the blob would be too large to
create from memory (as 'create_blob_fromstring' allows) and avoids having to
write the data to disk (as 'create_blob_fromworkdir' allows). The latter
operation is especially useful when reading data from a network socket, since
it avoids having to first commit all the data to disk.
This is the function which does the work for Repository.merge_commits()
and allows us more direct control over which trees we want to merge,
including trees which do not belong to commits.
As we allow users of the library to use short strings, we must expand
them. This is however only available through a function in C. Expose
that function from the repository to allow python code to get a full id
from a short hex string.
Move to use git_remote_push() instead of doing the steps ourselves. We
also change to accept a list of refspecs instead of just the one refspec
for the push method.
As part of this, we no longer error out if the server rejected any
updates, as this is a different concern from whether the push itself
failed or not. We do still error out if we attempt to push non-ff
updates.
Apart from the usual API changes, we now need to introduce the concept
of whether we still own the C object underneath our Repository and
Remote objects.
When using the custom callbacks for repository and remote creation
during clone, we pass the pointer and thus ownership of the object back
to the library. We will then get the repository back at the end.
We return the object which was handed to us rather than opening the
repository again with the local path as there is now a much higher
chance that the cloned repository does not use the standard backends.
This lets us look up remotes by name, which is not possible by just
returning the list of remotes.
Move remote creation to Repostiory.remotes.create() and keep the old
Repository.create_remote() for compatibility, delegating to this new
way.
Existing code should keep working, but this moves us towards what we'd
need for a better interface in 0.22 which makes remote renaming and
deleting work with a name rather than an instance and would make sense
to exist as part of an Remote.remotes object.
It is not possible to know how we can free the results of this
allocation, so we shouldn't be using this function.
We have a convention of returning Oid objects in pygit2, so let's keep
to that in these places.
I've gone with taking a string and converting it because the depth of
the namespacing in the libgit2 name is rather large and we don't care
about the global namespace that C has; and this also lets us pass the
same as the '-X' option to git-merge.
Add Repository.write_archive() to write a given tree to an archive. As
there are many customisation options, we only provide a method to write
to an archive which is created by the user.
Following from the previous commits, make 'head' read-only and provide a
method to update head while providing a message.
The checkout() codepath which switches branches has been updated to
provide a reflog entry which mimics git's.
This requires fairly little work on the pygit2 side to kick off all the
searching on the libgit2 side, so it's a fairly good candidate.
This changes the return value for the commit ids to Oid instead of
strings, which is what we generally try to return.
Updating the target of a reference is not like setting a property. It
involves appending to the reflog under the same lock, so we must do it
all the same time. Thus setting the target becomes a function which
takes the new target and what the use would like to add to the reflog.
We were missing a cast to bytes. Add a test for this option as well and
remove the old commented-out test for checkout_branch, which is
superseded by this one and whose last bit seemed confused about what the
option means.
This fixes #399
At its core, the config is a key-value storage with peculiar key
equality rules. Make it behave more like a python dictionary and return
the key on iteration.
Renaming a remote in pygit2 has been done via Remote.name= up to now,
but this is inherently unsafe, as it provides no way to pass up the
refspecs that libgit2 was unable to remap.
In fact, if there ever was such problem, we would have segfaulted.
libgit2 now provides a much more direct way of getting back the results,
so expose it as the return value of Remote.rename(). This also removes
the hint that a rename might be something that happens only to the
in-memory structure.
Reconcile the changes between the ffi changes upstream with the changes
to libgit2 in the dev branch.
Conflicts:
src/config.c
src/options.c
src/refspec.c
src/remote.c