Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
dccb5d7
Add libgit2 dir.
xtao May 20, 2013
ec976a3
Update libgit2
xtao May 20, 2013
29370a8
Add support for libgit2 embed.
xtao May 20, 2013
657ec17
Add submodule init to setup.py
xtao May 20, 2013
79c45c2
Add diff options: context_lines and paths.
xtao May 20, 2013
43b32ac
Add type check for diff option paths.
xtao May 20, 2013
e7c05db
Fix setup.py for popen
xtao May 21, 2013
ed99b91
Merge branch 'diff' into code/master
xtao May 21, 2013
05967d8
Fix linking git2 order.
xtao May 21, 2013
f859750
Update libgit2 repo url to code.
xtao May 27, 2013
7e07569
Merge pull request #1 from xutao/pygit2:libgit2
xtao May 27, 2013
f4b9354
Add additions and deletions for patch.
xtao May 28, 2013
2c93405
Merge pull request #2 from xutao/pygit2:diffstat
xtao May 29, 2013
0a3f112
Add is_repository method.
May 29, 2013
290b493
Remove double linking libgit2.
xtao Jun 3, 2013
8548d60
Bump libgit2.
xtao Jun 9, 2013
74033c0
Add support libgit2 development.
xtao Jun 9, 2013
241e160
Fix memory leak.
xtao Jun 10, 2013
1f5903a
Merge pull request #5 from xutao/pygit2:libgit2
xtao Jul 19, 2013
fb72bfc
Bump libgit2.
xtao Jul 19, 2013
8b02a1e
Merge remote-tracking branch 'pygit2/master' into libgit2
xtao Jul 20, 2013
6a31517
Add some compatibility.
xtao Jul 21, 2013
59aac8d
Merge pull request #6 from xutao/pygit2:libgit2
xtao Jul 22, 2013
41fc0ba
Add is_changed for commit.
xtao Jul 27, 2013
79c0318
Add unit test for commit.is_changed()
xtao Jul 28, 2013
9b3a33b
Merge pull request #7 from xutao/pygit2:history
xtao Jul 28, 2013
ab539b2
Refactor commit.is_changed()
xtao Jul 31, 2013
05be609
Merge pull request #8 from xutao/pygit2:history
xtao Jul 31, 2013
01a08e2
Fix commit.is_changed directory path.
xtao Jul 31, 2013
90f3a46
Add no_diff to commit.is_changed()
xtao Jul 31, 2013
4d92828
Merge pull request #9 from xutao/pygit2:history
xtao Jul 31, 2013
e176ef3
Fix no_diff bug.
xtao Aug 1, 2013
8d90481
Refactor commit.is_changed()
xtao Aug 1, 2013
64e3340
Add thread to commit.is_changed()
xtao Aug 1, 2013
68ee8a6
Fix is_changed memory leaks.
xtao Aug 2, 2013
f9c5a46
Add append_log to reference.
xtao Aug 6, 2013
b7ab4d8
Merge pull request #11 from xutao/pygit2:reflog
xtao Aug 6, 2013
e8ba444
Merge pull request #10 from xutao/pygit2:history
xtao Aug 6, 2013
298f941
tag: add get_object() method
aiiie Aug 15, 2013
68969ad
Add blob.binary
xtao Aug 16, 2013
c31b1ff
Merge pull request #12 from xutao/pygit2:binary
xtao Aug 16, 2013
6d87567
tag: fix incorrect doc string wording for get_object()
aiiie Aug 16, 2013
b55650e
commit: rename Commit._message to Commit.raw_message
aiiie Aug 19, 2013
aec44c9
signature: rename Signature._name/_email to Signature.raw_name/raw_email
aiiie Aug 19, 2013
3d6225d
Merge branch 'brodie/signature-raw-name-email' into bitbucket
aiiie Aug 19, 2013
87f0d1d
Add patch.binary
xtao Aug 21, 2013
723dfc2
Merge pull request #13 from xutao/pygit2:delta
xtao Aug 21, 2013
af68816
Make pygit2.TreeBuilder() to fail (issue #265)
jdavid Aug 24, 2013
d4cde25
Change libgit2 to github.
xtao Aug 25, 2013
4544aae
Add paths to diff.
xtao Aug 27, 2013
5f58257
Add paths to docs.
xtao Aug 27, 2013
921d2fc
Merge pull request #14 from xutao/pygit2:diff_path
xtao Aug 27, 2013
179c7db
Don't forget to remove the temporary directory in the config tests
carlosmn Aug 29, 2013
74b1628
test utils: implement a repo context manager
frasertweedale Aug 29, 2013
134d87a
implement push support
frasertweedale Aug 25, 2013
73941b5
add diff.size
Aug 30, 2013
e86f2f8
using PyObject* and PyLong_FromSize_t
Aug 30, 2013
2d55a84
for add diff.size
Aug 30, 2013
8522067
Merge pull request #15 from huanghuang/pygit2:size
xtao Aug 30, 2013
d5c0a23
Doc fixes: change head.oid to head.target in examples
eminence Sep 1, 2013
bde9639
Merge remote-tracking branch 'fraser/feature/push'
jdavid Sep 2, 2013
ce131ca
Bump libgit2.
xtao Sep 20, 2013
f50ccb1
Fix finalize_write argument order.
xtao Sep 20, 2013
15f6acd
Merge remote-tracking branch 'pygit2/master' into libgit2
xtao Sep 20, 2013
68968ad
Fix multivar interface.
xtao Sep 20, 2013
95b9f0e
Rename orphan to unborn.
xtao Sep 20, 2013
aaf8195
Merge pull request #16 from xutao/pygit2:libgit2
xtao Sep 21, 2013
687d5dc
Fix repository.write
xtao Sep 27, 2013
0674872
Merge pull request #17 from xutao/pygit2:libgit2
xtao Sep 27, 2013
7f31455
Merge remote-tracking branch 'code/master' into douban
xtao Oct 29, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/libgit2"]
path = vendor/libgit2
url = https://github.com/libgit2/libgit2.git
5 changes: 5 additions & 0 deletions docs/objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ committer and others.
.. autoattribute:: pygit2.Commit.committer
.. autoattribute:: pygit2.Commit.message
.. autoattribute:: pygit2.Commit.message_encoding
.. autoattribute:: pygit2.Commit.raw_message
.. autoattribute:: pygit2.Commit.tree
.. autoattribute:: pygit2.Commit.parents
.. autoattribute:: pygit2.Commit.commit_time
Expand All @@ -232,7 +233,9 @@ objects::
<pygit2.Signature object at 0x7f75e9b1f5f8>

.. autoattribute:: pygit2.Signature.name
.. autoattribute:: pygit2.Signature.raw_name
.. autoattribute:: pygit2.Signature.email
.. autoattribute:: pygit2.Signature.raw_email
.. autoattribute:: pygit2.Signature.time
.. autoattribute:: pygit2.Signature.offset

Expand Down Expand Up @@ -267,6 +270,8 @@ A tag is a static label for a commit. See references for more information.
.. autoattribute:: pygit2.Tag.tagger
.. autoattribute:: pygit2.Tag.message

.. automethod:: pygit2.Tag.get_object


Creating tags
--------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/git-log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Show HEAD commit

.. code-block:: python

>>> commit = repo[repo.head.oid]
>>> commit = repo[repo.head.target]
>>> commit.message
'commit message'

Expand All @@ -30,7 +30,7 @@ Traverse commit history

.. code-block:: python

>>> last = repo[repo.head.oid]
>>> last = repo[repo.head.target]
>>> for commit in repo.walk(last.oid, pygit2.GIT_SORT_TIME):
>>> print(commit.message) # or some other operation

Expand Down
2 changes: 1 addition & 1 deletion docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Example. These two lines are equivalent::

.. autoattribute:: pygit2.Repository.head
.. autoattribute:: pygit2.Repository.head_is_detached
.. autoattribute:: pygit2.Repository.head_is_orphaned
.. autoattribute:: pygit2.Repository.head_is_unborn

Branches
====================
Expand Down
1 change: 1 addition & 0 deletions docs/remotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ The Remote type
.. autoattribute:: pygit2.Remote.refspec_count
.. automethod:: pygit2.Remote.get_refspec
.. automethod:: pygit2.Remote.fetch
.. automethod:: pygit2.Remote.push
.. automethod:: pygit2.Remote.save
9 changes: 6 additions & 3 deletions pygit2/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def checkout(self, refname=None, strategy=GIT_CHECKOUT_SAFE_CREATE):
# Diff
#
def diff(self, a=None, b=None, cached=False, flags=GIT_DIFF_NORMAL,
context_lines=3, interhunk_lines=0):
context_lines=3, interhunk_lines=0, paths=None):
"""
Show changes between the working tree and the index or a tree,
changes between the index and a tree, changes between two trees, or
Expand All @@ -156,6 +156,9 @@ def diff(self, a=None, b=None, cached=False, flags=GIT_DIFF_NORMAL,
the maximum number of unchanged lines between hunk
boundaries before the hunks will be merged into a one

paths
paths to diff

Examples::

# Changes in the working tree not yet staged for the next commit
Expand Down Expand Up @@ -192,8 +195,8 @@ def treeish_to_tree(obj):
a = treeish_to_tree(a) or a
b = treeish_to_tree(b) or b

opt_keys = ['flags', 'context_lines', 'interhunk_lines']
opt_values = [flags, context_lines, interhunk_lines]
opt_keys = ['flags', 'context_lines', 'interhunk_lines', 'paths']
opt_values = [flags, context_lines, interhunk_lines, paths]

# Case 1: Diff tree to tree
if isinstance(a, Tree) and isinstance(b, Tree):
Expand Down
40 changes: 34 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from subprocess import Popen, PIPE
import sys
import unittest
import shutil

# Read version from local pygit2/version.py without pulling in
# pygit2/__init__.py
Expand All @@ -53,19 +54,46 @@
else:
u = str

print('checkout libgit2 source')
popen = Popen(['git', 'submodule', 'update', '--init'], stdout=PIPE, stderr=PIPE)
stdoutdata, stderrdata = popen.communicate()
if popen.returncode != 0:
print(stderrdata)
sys.exit()

pygit2_libs = ['git2']
# Use environment variable LIBGIT2 to set your own libgit2 configuration.
libgit2_path = os.getenv("LIBGIT2")
if libgit2_path is None:
if libgit2_path:
libgit2_bin = os.path.join(libgit2_path, 'bin')
libgit2_include = os.path.join(libgit2_path, 'include')
libgit2_lib = os.getenv('LIBGIT2_LIB', os.path.join(libgit2_path, 'lib'))
else:
if os.name == 'nt':
program_files = os.getenv("ProgramFiles")
libgit2_path = '%s\libgit2' % program_files
else:
libgit2_path = '/usr/local'
# use libgit2 embed
cwd = os.path.dirname(os.path.realpath(__file__))
libgit2_dir = os.path.join(cwd, 'vendor', 'libgit2')
libgit2_lib_path = cwd + "/libgit2_embed.a"
if os.path.isfile(libgit2_lib_path):
os.remove(libgit2_lib_path)
if not os.path.isfile(libgit2_lib_path):
os.chdir(libgit2_dir)
print('build libgit2 embed')
popen = Popen(['make', '-f', 'Makefile.embed'], stdout=PIPE, stderr=PIPE)
stdoutdata, stderrdata = popen.communicate()
if popen.returncode != 0:
print(stderrdata)
sys.exit()
shutil.copy('libgit2.a', libgit2_lib_path)
os.chdir(cwd)
libgit2_bin = ''
libgit2_include = os.path.join(libgit2_dir, 'include')
libgit2_lib = cwd
pygit2_libs = ['git2_embed']

libgit2_bin = os.path.join(libgit2_path, 'bin')
libgit2_include = os.path.join(libgit2_path, 'include')
libgit2_lib = os.getenv('LIBGIT2_LIB', os.path.join(libgit2_path, 'lib'))
pygit2_exts = [os.path.join('src', name) for name in os.listdir('src')
if name.endswith('.c')]

Expand Down Expand Up @@ -188,6 +216,6 @@ def get_file_list(self):
Extension('_pygit2', pygit2_exts,
include_dirs=[libgit2_include, 'include'],
library_dirs=[libgit2_lib],
libraries=['git2']),
libraries=pygit2_libs),
],
cmdclass=cmdclass)
12 changes: 12 additions & 0 deletions src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,24 @@ Blob_size__get__(Blob *self)
}


PyDoc_STRVAR(Blob_binary__doc__, "Binary.");

PyObject *
Blob_binary__get__(Blob *self)
{
if (git_blob_is_binary(self->blob))
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}


PyDoc_STRVAR(Blob_data__doc__,
"The contents of the blob, a bytes string. This is the same as\n"
"Blob.read_raw()");

PyGetSetDef Blob_getseters[] = {
GETTER(Blob, size),
GETTER(Blob, binary),
{"data", (getter)Object_read_raw, NULL, Blob_data__doc__, NULL},
{NULL}
};
Expand Down
Loading