534 Commits

Author SHA1 Message Date
Nico von Geyso
1bbb7b549f Added empty test repository 2012-11-01 16:17:29 +01:00
Nico von Geyso
0d2a3a6123 added Repository.is_detached
A repository's HEAD is detached when it points directly to a commit instead of branch.
You can use repo.is_detached to check this.
2012-11-01 15:35:53 +01:00
Nico von Geyso
971fc2f101 fixed config test for config.set_multivar
config files have different priorities and only the highest one gets evaluated for set_multivar
2012-11-01 15:18:07 +01:00
Nico von Geyso
b961b9218f fixed warning gcc -Wparentheses warning 2012-11-01 15:17:58 +01:00
Nico von Geyso
f1a72fb2e8 fixed index_add and index_get for current development branch of libgit2 2012-11-01 15:17:52 +01:00
delanne
0b537bf780 - add option flags for tree.diff
- add a testcase test_diff_tree_opts
 - update testrepo.git
 - update existing testcases
2012-10-31 12:11:18 +01:00
J. David Ibáñez
ee2813251b Merge pull request #142 from wking/readme-encoding
setup.py: decode README.rst to unicode.
2012-10-26 07:26:10 -07:00
J. David Ibáñez
86ed251fb7 Merge pull request #141 from wking/libgit2
Fix compilation issues against recent versions of libgit2
2012-10-26 07:10:56 -07:00
W. Trevor King
43a798bbdb setup.py: decode README.rst to unicode.
Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 15:47:02 -04:00
W. Trevor King
c36bbf518c test_config: tell Nose that foreach_test_wrapper() is not a test
Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 14:37:43 -04:00
W. Trevor King
e13a42a6e5 config: fix return conversion in Config_foreach_callback_wrapper()
PyLong_AsLong() returns -1 on error.  The previous implementation
returned -1 when py_result was 0, which killed every .foreach()
iteration after the first callback.

We could skip the if clause and just return the result of
PyLong_AsLong(), but keeping the if clause makes it more obvious that
we *did* think about handling errors from PyLong_AsLong().

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 14:24:55 -04:00
W. Trevor King
cce9f79905 config: return -1 on error in Config_foreach_callback_wrapper().
Config_foreach_callback_wrapper is supposed to return 0 on success.
From the docstring:

  As soon as one of the callbacks returns an integer other than 0,
  this function returns that value.

If we've already had an exception, we want to bail immediately and
raise the exception.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 14:15:15 -04:00
W. Trevor King
cd643a3d70 config: check for Py_BuildValue() errors in Config_foreach_callback_wrapper().
Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 14:14:39 -04:00
W. Trevor King
4660c9c149 config: extend Config.add_file() accept keyword arguments.
This provides backward compatibility with older code that does not
specify `force`.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 13:52:15 -04:00
W. Trevor King
ebdb85e754 index: remove read_tree() progress indicator
This brings us into compliance with the libgit2 commit:

  commit 0ae81fc479bf3cf7ed31b3e3b070de7990102f1d
  Author: nulltoken <emeric.fermas@gmail.com>
  Date:   Wed Oct 17 15:30:22 2012 +0200

    index: remove read_tree() progress indicator

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 13:23:18 -04:00
W. Trevor King
01d2fdc508 diff: add const to shared pointers in the diff API.
This brings us into compliance with the libgit2 commit:

  commit bae957b95d59a840df72a725b06f00635471cfd8
  Author: Russell Belfer <rb@github.com>
  Date:   Tue Sep 25 16:31:46 2012 -0700

    Add const to all shared pointers in diff API

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 11:03:16 -04:00
W. Trevor King
396fbef698 config: update Config_foreach_callback_wrapper to use git_config_entry *.
This fixes:

  $ python setup.py build_ext --inplace
  src/pygit2/config.c: In function ‘Config_foreach’:
  src/pygit2/config.c:261:13: warning: passing argument 2 of ‘git_config_foreach’ from incompatible pointer type
  ../libgit2/include/git2/config.h:420:17: note: expected ‘int (*)(const struct git_config_entry *, void *)’ but argument is of type ‘int (*)(const char *, const char *, void *)’

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 10:54:38 -04:00
W. Trevor King
86075d3f50 config: add force argument to Config_add_file.
This fixes:

  src/pygit2/config.c: In function ‘Config_add_file’:
  src/pygit2/config.c:276:5: error: too few arguments to function ‘git_config_add_file_ondisk’

Also convert `int priority` -> `unsigned int level` to match current
libgit2 header.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 10:28:45 -04:00
W. Trevor King
53cd040bad config: update Config_get_multivar_fn_wrapper to use git_config_entry *.
This fixes:

  $ python setup.py build_ext --inplace
  ...
  src/pygit2/config.c: In function ‘Config_get_multivar’:
  src/pygit2/config.c:311:13: warning: passing argument 4 of ‘git_config_get_multivar’ from incompatible pointer type
  ../libgit2/include/git2/config.h:339:17: note: expected ‘int (*)(const struct git_config_entry *, void *)’ but argument is of type ‘int (*)(const char *, void *)’
  error: command 'i686-pc-linux-gnu-gcc' failed with exit status 1

reported by wolftankk in issue #140.

Signed-off-by: W. Trevor King <wking@tremily.us>
2012-10-25 10:21:01 -04:00
Nico von Geyso
e1acdb48bc use latest development of libgit2 - changed GitError to ValueError
For already existing references a ValueError is raised (see sry/pygit2/error.c:41)
2012-10-12 11:51:08 +02:00
Nico von Geyso
682fb1fd13 merged create_reference and create_reference_symbolic and added force-Option
To be more pythonic: merged methods create_reference and create_reference_symbolic
and added force-Option. To make a new symbolic reference you have provide symbolic=True
as an additional parameter. If force=True references will although be overridden.
Otherwise an exception is raised if the references exists.

Examples:

  # normal reference
    repo.create_reference('refs/heads/foo', repo.head.hex)

  # override reference with new value
    repo.create_reference('refs/heads/foo', repo.head.hex, force=True)

  # symbolic reference
    repo.create_reference('refs/tags/foo', 'refs/heads/master', symbolic = True)
2012-10-09 13:13:36 +02:00
J. David Ibáñez
87572b2c8c Merge remote-tracking branch 'cholin/master' 2012-10-03 15:06:39 +02:00
J. David Ibáñez
ad8103bc48 Fix reference test case
Now git_reference_lookup says "foo" is an invalid reference name
(returns GITERR_REFERENCE instead of GIT_ENOTFOUND).
2012-10-03 14:08:27 +02:00
Nico von Geyso
63e0c0a3ad added build status image to README 2012-09-26 12:18:11 +02:00
J. David Ibáñez
5251343ee7 Merge remote-tracking branch 'wking/revparse' 2012-09-25 15:10:55 +02:00
J. David Ibáñez
3e9daa4ae3 import pygit2 works again (diff tests still fail) 2012-09-23 15:12:46 +02:00
J. David Ibáñez
a1edbe0b86 Fix compilation warnings 2012-09-23 15:10:05 +02:00
J. David Ibáñez
1be3e8301d Get a useful traceback when importing pygit2 fails 2012-09-22 19:07:15 +02:00
J. David Ibáñez
ded3d91eab Fix compilation 2012-09-21 23:31:43 +02:00
J. David Ibáñez
ce652548dc Merge remote-tracking branch 'encukou/git_filemode' 2012-09-21 17:04:20 +02:00
J. David Ibáñez
2dcd4bcfed Merge remote-tracking branch 'ferengee/patch-1' 2012-09-21 17:00:03 +02:00
J. David Ibáñez
a72fab5a76 Merge remote-tracking branch 'bendavis/git_tree_entry_bypath' 2012-09-21 16:52:38 +02:00
J. David Ibáñez
1c7a18724c Switch to use libgit2's development branch 2012-09-21 16:44:13 +02:00
J. David Ibáñez
1148c5d73b Release v0.17.3
Features:

- New 'Blob.size' getter
- New 'Repository.create_blob_fromfile' method
- Signature, now the time and offset parameters are optional
- Improved diff support

Other:

- Add 'pygit2.__version__'
- Optimize usage of Travis
- Various fixes for the unit tests
- Various documentation improvements

Thanks to Alex Chamberlain, Carlos Martín Nieto, Eric Davis,
Eric Schrijver, Petr Viktorin, Ridge Kennedy and W. Trevor King.
v0.17.3
2012-09-21 16:30:50 +02:00
J. David Ibáñez
6654716eb3 Merge remote-tracking branch 'wking/kwargs-signature' 2012-09-19 20:34:43 +02:00
W. Trevor King
36ae908de2 test: use Signature(encoding=...) in test_commit and test_signature.
Correct tests now that the default name encoding is ASCII.
2012-09-17 14:52:30 -04:00
W. Trevor King
b3b7e98f92 README: Update Signature examples to use the default time arguments. 2012-09-17 14:52:30 -04:00
W. Trevor King
50793b673c signature: Add keyword argument parsing to Signature().
Now you can specify `encoding` without bothering with `time` or
`offset`.
2012-09-17 14:51:41 -04:00
W. Trevor King
f10d2b7b3f pygit2:version: add 'pygit2.__version__' for easy access from client software.
Moved the hardcoded version from setup.py to pygit2/version.py so
client software can figure out which version of pygit2 it's using.
Having setup.py import pygit2.version.__version__ removes duplication,
and also means that setup.py will always use the local version (and
not the version of a previously installed pygit2).
2012-09-17 10:16:25 -04:00
Ridge Kennedy
bc0c0e17a8 Add Blob.size 2012-09-16 22:56:36 +12:00
J. David Ibáñez
430f4dc343 Fix typo in repository test 2012-09-14 14:04:02 +02:00
W. Trevor King
0238fb72df repository: add Repository.revparse_single().
This provides access to libgit2's 'git_revparse_single'.
2012-09-13 17:09:12 -04:00
W. Trevor King
5464eaaf50 Merge branch 'test_repository' into revparse
Get the correct HEAD_SHA for the upcoming revparse_single test.
2012-09-13 17:00:35 -04:00
W. Trevor King
437c1af33f test_repository: fix HEAD_SHA -> 2cdae2 and use assertEqual when testing.
The previous test always passed, because bool(HEAD_SHA) is True.

The update to HEAD_SHA should have happened in:

  commit c06e10e67e746099b8d454212acc56391199eb31
  Author: Petr Hosek <p.hosek@imperial.ac.uk>
  Date:   Tue May 29 17:41:07 2012 +0100

    Support for diff merge operation added
2012-09-13 16:54:07 -04:00
W. Trevor King
cc7f137f7b object: factor wrap_object out of lookup_object_prefix.
Generating an `Object *` from a `git_object *` may be useful in other
functions (e.g. the upcoming `Repository_revparse_single`).
2012-09-13 16:41:56 -04:00
W. Trevor King
b66fa71bae Merge branch 'libgit2-dev' into revparse
`git_revparse_single` only dates back to

  commit ac250c56c7d7bb11691c9dfbcd0dbf580d85e177
  Author: Ben Straub <bstraub@github.com>
  Date:   Wed Apr 25 16:24:22 2012 -0700

    First stab at implementation of rev-parse.

which is not included in libgit2 0.17.0.  We need to pull in these
patches to work with the current `development` branch of libgit2,
which does include the revparse code.
2012-09-13 16:37:30 -04:00
W. Trevor King
477e48ef6c test_diff: hunk.old_lines should be 1 in test_diff_tree and test_diff_merge.
In both cases, the file contents change from 'X contents\n' to 'X
contents 2\n' (where 'X' is 'a' or 'b').  This means were removing one
line and adding another.

I'm not sure how this test was passing against libgit2 v0.17.0, so I
may be missing something important.
2012-09-13 16:30:21 -04:00
W. Trevor King
651aa6a830 tree: rename Tree.attributes to Tree.filemode.
This catches up with changes in libgit2:

  commit 9d7ac675d06dab2e000ad32f9248631af0191f85
  Author: nulltoken <emeric.fermas@gmail.com>
  Date:   Tue Aug 21 11:45:16 2012 +0200

    tree entry: rename git_tree_entry_attributes() into git_tree_entry_filemode()
2012-09-13 16:14:24 -04:00
W. Trevor King
8e19102815 index: Add NULL stats argument to git_index_read_tree call.
This catches up with changes in libgit2:

  commit 4bf5115642b64851f9a32a8157010b588bf44103
  Author: Ben Straub <bstraub@github.com>
  Date:   Mon Jul 30 14:52:46 2012 -0700

    Enable stats on git_index_read_tree.

    Replace with the contents of
    git_index_read_tree_with_stats() and improve
    documentation comments.
2012-09-13 13:53:37 -04:00
W. Trevor King
91e211d4f9 error: replace GIT_REVWALKOVER with GIT_ITEROVER.
This catches up with changes in libgit2:

  commit f335ecd6e126aa9dea28786522c0e6ce71596e91
  Author: Russell Belfer <rb@github.com>
  Date:   Thu Aug 30 14:24:16 2012 -0700
2012-09-13 13:48:00 -04:00