From 78d134c016f88921dc54c3f237107fbd8534934d Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Wed, 8 Jan 2014 15:14:27 -0800 Subject: [PATCH 01/10] repository: add listall_reference_objects() method This allows for efficient reading of many references and their targets, without incurring the overhead of lookup_reference() (which stats for a loose ref and then reads packed-refs) which can be expensive on NFS with thousands of refs. --- docs/references.rst | 1 + src/repository.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ src/repository.h | 2 ++ test/test_refs.py | 11 ++++++++++ 4 files changed, 65 insertions(+) diff --git a/docs/references.rst b/docs/references.rst index 3391392..0682f0e 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -4,6 +4,7 @@ References .. contents:: +.. automethod:: pygit2.Repository.listall_reference_objects .. automethod:: pygit2.Repository.listall_references .. automethod:: pygit2.Repository.lookup_reference diff --git a/src/repository.c b/src/repository.c index f8d42a7..e83302c 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1123,6 +1123,56 @@ out: } +PyDoc_STRVAR(Repository_listall_reference_objects__doc__, + "listall_reference_objects() -> [Reference, ...]\n" + "\n" + "Return a list with all the reference objects in the repository."); + +PyObject * +Repository_listall_reference_objects(Repository *self, PyObject *args) +{ + git_reference_iterator *iter; + git_reference *ref = NULL; + int err; + PyObject *list; + + list = PyList_New(0); + if (list == NULL) + return NULL; + + if ((err = git_reference_iterator_new(&iter, self->repo)) < 0) + return Error_set(err); + + while ((err = git_reference_next(&ref, iter)) == 0) { + PyObject *py_ref = wrap_reference(ref, self); + if (py_ref == NULL) + goto error; + + err = PyList_Append(list, py_ref); + Py_DECREF(py_ref); + + if (err < 0) + goto error; + } + + git_reference_iterator_free(iter); + if (err == GIT_ITEROVER) + err = 0; + + if (err < 0) { + Py_CLEAR(list); + return Error_set(err); + } + + return list; + +error: + git_reference_iterator_free(iter); + Py_CLEAR(list); + return NULL; +} + + PyDoc_STRVAR(Repository_listall_branches__doc__, "listall_branches([flag]) -> [str, ...]\n" "\n" @@ -1643,6 +1693,7 @@ PyMethodDef Repository_methods[] = { METHOD(Repository, create_reference_direct, METH_VARARGS), METHOD(Repository, create_reference_symbolic, METH_VARARGS), METHOD(Repository, listall_references, METH_NOARGS), + METHOD(Repository, listall_reference_objects, METH_NOARGS), METHOD(Repository, listall_submodules, METH_NOARGS), METHOD(Repository, lookup_reference, METH_O), METHOD(Repository, revparse_single, METH_O), diff --git a/src/repository.h b/src/repository.h index 6947269..bc6cc38 100644 --- a/src/repository.h +++ b/src/repository.h @@ -58,6 +58,8 @@ PyObject* Repository_create_commit(Repository *self, PyObject *args); PyObject* Repository_create_tag(Repository *self, PyObject *args); PyObject* Repository_create_branch(Repository *self, PyObject *args); PyObject* Repository_listall_references(Repository *self, PyObject *args); +PyObject* Repository_listall_reference_objects(Repository *self, + PyObject *args); PyObject* Repository_listall_branches(Repository *self, PyObject *args); PyObject* Repository_lookup_reference(Repository *self, PyObject *py_name); diff --git a/test/test_refs.py b/test/test_refs.py index 53de205..9429146 100644 --- a/test/test_refs.py +++ b/test/test_refs.py @@ -42,6 +42,17 @@ LAST_COMMIT = '2be5719152d4f82c7302b1c0932d8e5f0a4a0e98' class ReferencesTest(utils.RepoTestCase): + def test_list_all_reference_objects(self): + repo = self.repo + + refs = [(ref.name, ref.target.hex) + for ref in repo.listall_reference_objects()] + self.assertEqual(sorted(refs), + [('refs/heads/i18n', + '5470a671a80ac3789f1a6a8cefbcf43ce7af0563'), + ('refs/heads/master', + '2be5719152d4f82c7302b1c0932d8e5f0a4a0e98')]) + def test_list_all_references(self): repo = self.repo From 456bf59a88b559bdea8af5090b4191842e976e96 Mon Sep 17 00:00:00 2001 From: Dustin Raimondi Date: Fri, 11 Mar 2016 09:38:08 -0500 Subject: [PATCH 02/10] bump libgit2 version number --- docs/install.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install.rst b/docs/install.rst index f8a3e84..2781c9e 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -65,8 +65,8 @@ directory, do: .. code-block:: sh $ wget https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz - $ tar xzf v0.23.4.tar.gz - $ cd libgit2-0.23.4/ + $ tar xzf v0.24.0.tar.gz + $ cd libgit2-0.24.0/ $ cmake . $ make $ sudo make install From f2864c0511956226d1ec8bc8e52c906727dbfea8 Mon Sep 17 00:00:00 2001 From: Dustin Raimondi Date: Fri, 11 Mar 2016 10:20:15 -0500 Subject: [PATCH 03/10] fix addition occurence of libgit2 version number --- docs/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.rst b/docs/install.rst index 2781c9e..83c95b4 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -64,7 +64,7 @@ directory, do: .. code-block:: sh - $ wget https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz + $ wget https://github.com/libgit2/libgit2/archive/v0.24.0.tar.gz $ tar xzf v0.24.0.tar.gz $ cd libgit2-0.24.0/ $ cmake . From 51915ddf0e319929653c7fc255f1536f4712928f Mon Sep 17 00:00:00 2001 From: Yu Jianjian Date: Wed, 23 Mar 2016 23:33:20 +0800 Subject: [PATCH 04/10] wrong order of the args in docstring of write_archive --- pygit2/repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygit2/repository.py b/pygit2/repository.py index e9bbdc6..985694f 100644 --- a/pygit2/repository.py +++ b/pygit2/repository.py @@ -765,7 +765,7 @@ class Repository(_Repository): >>> import tarfile, pygit2 >>>> with tarfile.open('foo.tar', 'w') as archive: >>>> repo = pygit2.Repsitory('.') - >>>> repo.write_archive(archive, repo.head.target) + >>>> repo.write_archive(repo.head.target, archive) """ # Try to get a tree form whatever we got From 270dad8cd39b0f1dbb34256b389eb1bb458779de Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 15 Apr 2016 14:07:33 +0200 Subject: [PATCH 05/10] repository: SYMTYPE is constant in module tarfile, not in any class Reference: https://github.com/libgit2/pygit2/issues/618 Signed-off-by: Igor Gnatenko --- pygit2/repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygit2/repository.py b/pygit2/repository.py index 985694f..04935d2 100644 --- a/pygit2/repository.py +++ b/pygit2/repository.py @@ -799,7 +799,7 @@ class Repository(_Repository): info.mtime = timestamp info.uname = info.gname = 'root' # just because git does this if entry.mode == GIT_FILEMODE_LINK: - info.type = archive.SYMTYPE + info.type = tarfile.SYMTYPE info.linkname = content info.mode = 0o777 # symlinks get placeholder info.size = 0 From fd9a39a91b11964b8b88fdb4caf51ffdc559a6fa Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 15 Apr 2016 14:13:47 +0200 Subject: [PATCH 06/10] repository: decode() linkname Reference: https://github.com/libgit2/pygit2/issues/620 Signed-off-by: Igor Gnatenko --- pygit2/repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygit2/repository.py b/pygit2/repository.py index 985694f..04783b7 100644 --- a/pygit2/repository.py +++ b/pygit2/repository.py @@ -800,7 +800,7 @@ class Repository(_Repository): info.uname = info.gname = 'root' # just because git does this if entry.mode == GIT_FILEMODE_LINK: info.type = archive.SYMTYPE - info.linkname = content + info.linkname = content.decode("utf-8") info.mode = 0o777 # symlinks get placeholder info.size = 0 archive.addfile(info) From 50c0569cf0090139ccde82959a0ac1607f4719f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=BD?= Date: Mon, 18 Apr 2016 21:58:58 +0200 Subject: [PATCH 07/10] Fixed typo --- src/repository.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/repository.c b/src/repository.c index f8d42a7..1014e1c 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1575,8 +1575,8 @@ PyDoc_STRVAR(Repository_reset__doc__, "\n" "Resets current head to the provided oid.\n" "reset_type:\n" - "GIT_RESET_SOFT: resets head to point to oid, but does not modfy working copy, and leaves the changes in the index.\n" - "GIT_RESET_MIXED: resets head to point to oid, but does not modfy working copy. It empties the index too.\n" + "GIT_RESET_SOFT: resets head to point to oid, but does not modify working copy, and leaves the changes in the index.\n" + "GIT_RESET_MIXED: resets head to point to oid, but does not modify working copy. It empties the index too.\n" "GIT_RESET_HARD: resets head to point to oid, and resets too the working copy and the content of the index.\n"); PyObject * From df30f9213fbd2ac2d65598f37157baff93741751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 29 Apr 2016 13:19:32 +0200 Subject: [PATCH 08/10] Remove checks for obsolete methods This is not how you define your callbacks, so this test isn't testing for anything useful. --- test/test_remote.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/test/test_remote.py b/test/test_remote.py index dd01d96..489a6ae 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -188,21 +188,6 @@ class RepositoryTest(utils.RepoTestCase): end = sys.getrefcount(self.repo) self.assertEqual(start, end) - def test_remote_callback_typecheck(self): - remote = self.repo.remotes[0] - remote.progress = 5 - self.assertRaises(TypeError, remote, 'fetch') - - remote = self.repo.remotes[0] - remote.transfer_progress = 5 - self.assertRaises(TypeError, remote, 'fetch') - - remote = self.repo.remotes[0] - remote.update_tips = 5 - self.assertRaises(TypeError, remote, 'fetch') - - - class EmptyRepositoryTest(utils.EmptyRepoTestCase): def test_fetch(self): remote = self.repo.remotes[0] From 5dcc793aff84dafe2d8226bcaaa3ba25f99ac290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=BD?= Date: Tue, 7 Jun 2016 22:33:46 +0200 Subject: [PATCH 09/10] Make build reproducible https://wiki.debian.org/ReproducibleBuilds --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 37134e8..65dec19 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ else: libgit2_bin, libgit2_include, libgit2_lib = get_libgit2_paths() -pygit2_exts = [os.path.join('src', name) for name in listdir('src') +pygit2_exts = [os.path.join('src', name) for name in sorted(listdir('src')) if name.endswith('.c')] From 4416f65fe12155e6da6bbe174a752608dce6d652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Tue, 21 Jun 2016 23:04:12 +0200 Subject: [PATCH 10/10] Release 0.24.1 --- README.rst | 42 +++++++++++++++++++++++++++++++++--------- docs/general.rst | 10 +++++----- docs/install.rst | 16 ++++++++-------- pygit2/_build.py | 2 +- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/README.rst b/README.rst index b7c37ca..893b0f4 100644 --- a/README.rst +++ b/README.rst @@ -25,6 +25,29 @@ How to install Changelog ============== +0.24.1 (2016-06-21) +------------------------- + +- New ``Repository.listall_reference_objects()`` + `#634 `_ + +- Fix ``Repository.write_archive(...)`` + `#619 `_ + `#621 `_ + +- Reproducible builds + `#636 `_ + +- Documentation fixes + `#606 `_ + `#607 `_ + `#609 `_ + `#623 `_ + +- Test updates + `#629 `_ + + 0.24.0 (2016-03-05) ------------------------- @@ -774,7 +797,7 @@ Other: `#331 `_ Authors ============== -104 developers have contributed at least 1 commit to pygit2:: +108 developers have contributed at least 1 commit to pygit2:: J. David Ibáñez Carlos Martín Nieto Nico von Geyso W. Trevor King Dave Borowitz Daniel Rodríguez Troitiño @@ -783,19 +806,20 @@ Authors Matthew Duggan Matthew Gamble Martin Lenders Petr Hosek Victor Garcia Xavier Delannoy Yonggang Luo Patrick Steinhardt Valentin Haenel - Michael Jones Bernardo Heynemann John Szakmeister - Vlad Temian Brodie Rao Nicolas Dandrimont + Michael Jones Bernardo Heynemann Brodie Rao + John Szakmeister Vlad Temian Nicolas Dandrimont David Versmisse Rémi Duraffort Santiago Perez De Rosso Sebastian Thiel Thom Wiggers Alok Singhal Fraser Tweedale Han-Wen Nienhuys Leonardo Rhodes Petr Viktorin Ron Cohen Thomas Kluyver Alex Chamberlain Alexander Bayandin Amit Bakshi Andrey Devyatkin Arno van Lumig Ben Davis - Eric Schrijver Greg Fitzgerald Hervé Cauwelier - Huang Huang Ian P. McCullough Jack O'Connor - Jared Flatow Jiunn Haur Lim Jun Omae - Kaarel Kitsemets Kevin KIN-FOO Masud Rahman - Michael Sondergaard Sarath Lakshman Vicent Marti + Dustin Raimondi Eric Schrijver Greg Fitzgerald + Hervé Cauwelier Huang Huang Ian P. McCullough + Igor Gnatenko Jack O'Connor Jared Flatow + Jiunn Haur Lim Jun Omae Kaarel Kitsemets + Kevin KIN-FOO Masud Rahman Michael Sondergaard + Ondřej Nový Sarath Lakshman Vicent Marti Zoran Zaric Adam Spiers Andrew Chin András Veres-Szentkirályi Ash Berlin Benjamin Kircher Benjamin Pollack Bryan O'Sullivan Cam Cope @@ -810,7 +834,7 @@ Authors Óscar San José Peter Dave Hello Philippe Ombredanne Ridge Kennedy Ross Nicoll Rui Abreu Ferreira Sheeo Soasme Vladimir Rutsky - chengyuhang earl + Yu Jianjian chengyuhang earl License diff --git a/docs/general.rst b/docs/general.rst index c84d0cb..4afdcaa 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -18,7 +18,7 @@ library that has been built against. The version number has a .. py:data:: LIBGIT2_VER_MAJOR Integer value of the major version number. For example, for the version - ``0.24.0``:: + ``0.24.1``:: >>> print LIBGIT2_VER_MAJOR 0 @@ -26,7 +26,7 @@ library that has been built against. The version number has a .. py:data:: LIBGIT2_VER_MINOR Integer value of the minor version number. For example, for the version - ``0.24.0``:: + ``0.24.1``:: >>> print LIBGIT2_VER_MINOR 24 @@ -34,17 +34,17 @@ library that has been built against. The version number has a .. py:data:: LIBGIT2_VER_REVISION Integer value of the revision version number. For example, for the version - ``0.24.0``:: + ``0.24.1``:: >>> print LIBGIT2_VER_REVISION - 0 + 1 .. py:data:: LIBGIT2_VERSION The libgit2 version number as a string:: >>> print LIBGIT2_VERSION - '0.24.0' + '0.24.1' Errors ====== diff --git a/docs/install.rst b/docs/install.rst index 83c95b4..e89e841 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -43,11 +43,11 @@ while the last number |lq| *.micro* |rq| auto-increments independently. As illustration see this table of compatible releases: -+-----------+--------+----------------------------------------+ -|**libgit2**| 0.24.0 | 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4 | -+-----------+--------+----------------------------------------+ -|**pygit2** | 0.24.0 | 0.23.0, 0.23.1, 0.23.2, 0.23.3 | -+-----------+--------+----------------------------------------+ ++-----------+----------------+----------------------------------------+ +|**libgit2**| 0.24.0, 0.24.1 | 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4 | ++-----------+----------------+----------------------------------------+ +|**pygit2** | 0.24.0, 0.24.1 | 0.23.0, 0.23.1, 0.23.2, 0.23.3 | ++-----------+----------------+----------------------------------------+ .. warning:: @@ -64,9 +64,9 @@ directory, do: .. code-block:: sh - $ wget https://github.com/libgit2/libgit2/archive/v0.24.0.tar.gz - $ tar xzf v0.24.0.tar.gz - $ cd libgit2-0.24.0/ + $ wget https://github.com/libgit2/libgit2/archive/v0.24.1.tar.gz + $ tar xzf v0.24.1.tar.gz + $ cd libgit2-0.24.1/ $ cmake . $ make $ sudo make install diff --git a/pygit2/_build.py b/pygit2/_build.py index 533e7b9..c9a0b9c 100644 --- a/pygit2/_build.py +++ b/pygit2/_build.py @@ -37,7 +37,7 @@ from os import getenv # # The version number of pygit2 # -__version__ = '0.24.0' +__version__ = '0.24.1' #