Merge branch 'master' into oid
Conflicts: test/test_repository.py
This commit is contained in:
@@ -20,11 +20,12 @@ Pygit2 links:
|
||||
Quick install guide
|
||||
===================
|
||||
|
||||
1. Download libgit2 v0.17.0
|
||||
https://github.com/downloads/libgit2/libgit2/libgit2-0.17.0.tar.gz
|
||||
1. Checkout libgi2 v0.18.0::
|
||||
|
||||
$ git clone git://github.com/libgit2/libgit2.git -b v0.18.0
|
||||
|
||||
2. Build and install libgit2
|
||||
http://libgit2.github.com/#install
|
||||
https://github.com/libgit2/libgit2/#building-libgit2---using-cmake
|
||||
|
||||
3. Install pygit2 with *pip*::
|
||||
|
||||
@@ -52,6 +53,7 @@ pygit2 project (sorted alphabetically):
|
||||
- András Veres-Szentkirályi
|
||||
- Ben Davis
|
||||
- Benjamin Kircher
|
||||
- Benjamin Pollack
|
||||
- Bryan O'Sullivan
|
||||
- Carlos Martín Nieto
|
||||
- Christian Boos
|
||||
|
||||
@@ -48,9 +48,9 @@ copyright = u'2013, J. David Ibáñez'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.17'
|
||||
version = '0.18'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.17.3'
|
||||
release = '0.18.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -4,19 +4,18 @@ Diff
|
||||
|
||||
A diff shows the changes between trees, an index or the working dir::
|
||||
|
||||
>>> head = repo.revparse_single('HEAD')
|
||||
|
||||
# Diff two trees
|
||||
>>> t0 = repo.head.tree
|
||||
>>> t1 = repo.head.parents[0].tree
|
||||
>>> t0 = head.tree
|
||||
>>> t1 = head.parents[0].tree
|
||||
>>> diff = t1.diff(t0)
|
||||
>>> diff
|
||||
|
||||
# Diff a tree with the index
|
||||
>>> tree = repo.head.tree
|
||||
>>> diff = tree.diff(repo.index)
|
||||
>>> diff = head.tree.diff(repo.index)
|
||||
|
||||
# Diff a tree with the current working dir
|
||||
>>> tree = repo.head.tree
|
||||
>>> diff = tree.diff()
|
||||
>>> diff = head.tree.diff()
|
||||
|
||||
|
||||
The Diff type
|
||||
|
||||
@@ -10,9 +10,6 @@ In the first place Git is a key-value storage system. The values stored are
|
||||
called *objects*, there are four types (commits, trees, blobs and tags),
|
||||
for each type pygit2 has a Python class::
|
||||
|
||||
>>> # Get the last commit
|
||||
>>> head = repo.head
|
||||
|
||||
>>> # Show commits and trees
|
||||
>>> commit
|
||||
<pygit2.Commit object at 0x7f9d2f3000b0>
|
||||
|
||||
@@ -17,12 +17,11 @@ Reference log::
|
||||
>>> for entry in head.log():
|
||||
... print(entry.message)
|
||||
|
||||
The interface for RefLogEntry::
|
||||
Shortcuts::
|
||||
|
||||
RefLogEntry.committer -- Signature of Committer
|
||||
RefLogEntry.message -- the message of the RefLogEntry
|
||||
RefLogEntry.oid_old -- oid of old reference
|
||||
RefLogEntry.oid_new -- oid of new reference
|
||||
>>> # These two lines are equivalent
|
||||
>>> head = repo.head
|
||||
>>> head = repo.lookup_reference('HEAD').resolve()
|
||||
|
||||
|
||||
The Reference type
|
||||
@@ -40,6 +39,14 @@ The Reference type
|
||||
.. automethod:: pygit2.Reference.log
|
||||
|
||||
|
||||
The HEAD
|
||||
--------------------
|
||||
|
||||
.. autoattribute:: pygit2.Repository.head
|
||||
.. autoattribute:: pygit2.Repository.head_is_detached
|
||||
.. autoattribute:: pygit2.Repository.head_is_orphaned
|
||||
|
||||
|
||||
The reference log
|
||||
--------------------
|
||||
|
||||
@@ -48,7 +55,6 @@ The reference log
|
||||
.. autoattribute:: pygit2.RefLogEntry.message
|
||||
.. autoattribute:: pygit2.RefLogEntry.committer
|
||||
|
||||
|
||||
Notes
|
||||
====================
|
||||
|
||||
|
||||
@@ -41,6 +41,3 @@ To open an existing repository::
|
||||
.. autoattribute:: pygit2.Repository.is_empty
|
||||
.. automethod:: pygit2.Repository.read
|
||||
.. automethod:: pygit2.Repository.write
|
||||
.. autoattribute:: pygit2.Repository.head
|
||||
.. autoattribute:: pygit2.Repository.head_is_detached
|
||||
.. autoattribute:: pygit2.Repository.head_is_orphaned
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
__version__ = '0.17.4dev'
|
||||
__version__ = '0.18.0'
|
||||
|
||||
@@ -183,10 +183,7 @@ Repository_head__get__(Repository *self)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
oid = git_reference_target(head);
|
||||
pyobj = lookup_object(self, oid, GIT_OBJ_COMMIT);
|
||||
git_reference_free(head);
|
||||
return pyobj;
|
||||
return wrap_reference(head);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,11 +281,10 @@ Repository_revparse_single(Repository *self, PyObject *py_spec)
|
||||
{
|
||||
git_object *c_obj;
|
||||
char *c_spec;
|
||||
char *encoding = "ascii";
|
||||
int err;
|
||||
|
||||
/* 1- Get the C revision spec */
|
||||
c_spec = py_str_to_c_str(py_spec, encoding);
|
||||
c_spec = py_str_to_c_str(py_spec, NULL);
|
||||
if (c_spec == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ from os.path import join, realpath
|
||||
|
||||
# Import from pygit2
|
||||
from pygit2 import GIT_OBJ_ANY, GIT_OBJ_BLOB, GIT_OBJ_COMMIT
|
||||
from pygit2 import init_repository, discover_repository, Commit, hashfile
|
||||
from pygit2 import init_repository, discover_repository, Reference, hashfile
|
||||
from pygit2 import Oid
|
||||
import pygit2
|
||||
from . import utils
|
||||
@@ -63,7 +63,7 @@ class RepositoryTest(utils.BareRepoTestCase):
|
||||
def test_head(self):
|
||||
head = self.repo.head
|
||||
self.assertEqual(HEAD_SHA, head.hex)
|
||||
self.assertEqual(type(head), Commit)
|
||||
self.assertEqual(type(head), Reference)
|
||||
self.assertFalse(self.repo.head_is_orphaned)
|
||||
self.assertFalse(self.repo.head_is_detached)
|
||||
|
||||
@@ -194,10 +194,15 @@ class RepositoryTest_II(utils.RepoTestCase):
|
||||
lambda: self.repo.checkout(reference=ref_i18n))
|
||||
|
||||
# checkout i18n with GIT_CHECKOUT_FORCE
|
||||
self.assertTrue('new' not in self.repo.head.tree)
|
||||
head = self.repo.head
|
||||
head = self.repo[head.target]
|
||||
self.assertTrue('new' not in head.tree)
|
||||
self.repo.checkout(pygit2.GIT_CHECKOUT_FORCE, ref_i18n)
|
||||
self.assertEqual(self.repo.head.hex, self.repo[ref_i18n.target].hex)
|
||||
self.assertTrue('new' in self.repo.head.tree)
|
||||
|
||||
head = self.repo.head
|
||||
head = self.repo[head.target]
|
||||
self.assertEqual(head.hex, self.repo[ref_i18n.target].hex)
|
||||
self.assertTrue('new' in head.tree)
|
||||
self.assertTrue('bye.txt' not in self.repo.status())
|
||||
|
||||
def test_checkout_index(self):
|
||||
|
||||
Reference in New Issue
Block a user