58 Commits

Author SHA1 Message Date
J. David Ibáñez
d64dd15bd2 Merge remote-tracking branch 'carlos/merge-trees' 2015-02-10 09:34:49 +01:00
Carlos Martín Nieto
fcd4b9446b Introduce Repository.merge_trees()
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.
2015-02-09 21:21:28 +01:00
J. David Ibáñez
fa380c0adb Merge remote-tracking branch 'gandalf/archive_enh'
Conflicts:
	pygit2/repository.py
2015-02-07 20:35:45 +01:00
Carlos Martín Nieto
4709cae1a1 Add Repository.ahead_behind()
This lets us ask how many diverging commits each side of two histories
have.
2015-02-06 01:26:26 +01:00
Alok Singhal
f5a5dfc18a Use "prefix" instead of "root_path" in write_archive 2015-01-30 10:15:08 -08:00
Alok Singhal
3ee1c798b2 Add an option to specify root path when creating archives 2015-01-29 08:46:50 -08:00
Alok Singhal
9771adf862 Fix handling of symlinks in write_archive(). 2015-01-29 08:35:27 -08:00
Carlos Martín Nieto
1dbf94011a Migrate to 0.22
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.
2015-01-12 18:39:21 +01:00
J. David Ibáñez
beff871923 Minor styling 2014-11-12 10:21:47 +01:00
Carlos Martín Nieto
b80103b017 Introduce RemoteCollection
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.
2014-11-11 19:57:22 +01:00
J. David Ibáñez
cb310316bf docs: fix build errors in the blame chapter 2014-11-03 18:53:38 +01:00
Carlos Martín Nieto
bc8b29b4f3 Repository: allow passing a favor option to merge_commits
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.
2014-10-30 16:21:22 +01:00
Carlos Martín Nieto
3b27e16d08 Add Repository.merge_commits()
This allows you to merge arbitrary commits, returning an index, which is
useful when dealing with bare repos in which we want to merge.
2014-10-30 15:04:51 +01:00
Carlos Martín Nieto
59da03476e Repository: make use of peel for diff()
Instead of trying to reimplement parts of it, make use of Object.peel()
and Reference.peel() to get to a Blob or Tree.
2014-10-07 20:27:01 +02:00
J. David Ibáñez
510f6174f1 Fix Repository.diff for references an empty trees
This should fix issue #432

By the way make the code a little more robust.
2014-10-07 18:59:04 +02:00
Carlos Martín Nieto
ab730cb1d4 Provide a method to write a tree to an archive
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.
2014-09-06 18:59:15 +02:00
J. David Ibáñez
82167827bc Merge remote-tracking branch 'carlos/reference-update' 2014-09-05 17:11:32 +02:00
Carlos Martín Nieto
747e7c2136 Repository: make head read-only and introduce set_head()
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.
2014-09-04 01:58:05 +02:00
Carlos Martín Nieto
cd08425927 Move blame to cffi
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.
2014-08-31 22:35:32 +02:00
J. David Ibáñez
a53d8b2213 Merge remote-tracking branch 'djmattyg007/doc_fixes' 2014-08-26 10:31:53 +02:00
djmattyg007
629eea01e9 Allow objects of type Branch to be passed to Repository.checkout()
Branch inherits from Reference, so there's no reason why we shouldn't be
able to pass a Branch object.
2014-08-23 11:23:17 +10:00
djmattyg007
9718fd8c32 Add note about checkout('HEAD') being identical to checkout_head() 2014-08-23 01:08:32 +10:00
djmattyg007
2bd73f3bdf Clear up confusion regarding accepted types for Repository.checkout() refname parameter 2014-08-23 01:06:30 +10:00
J. David Ibáñez
be807a1dfc internal: split code for Python 2/3 compatibility 2014-07-28 17:51:51 +02:00
J. David Ibáñez
7df11bf817 internal: rename "to_str" to "to_bytes" for clarity 2014-07-28 17:30:38 +02:00
J. David Ibáñez
4c375907c5 Make checkout to fail on unexpected options 2014-07-19 12:22:34 +02:00
vtemian
93369b0a7c Cleanup a little bit the code 2014-07-14 20:21:24 +03:00
Carlos Martín Nieto
763b571c84 checkout: add support for overriding the target directory 2014-07-11 14:49:56 +02:00
Carlos Martín Nieto
af38211d0c checkout: move the code to cffi
As part of this, make the strategy part of **kwargs, in preparation for
supporting more options.
2014-07-11 14:42:29 +02:00
Carlos Martín Nieto
97ee7ab179 Move Index to cffi
This commit gives us feature-parity with the version in C.
2014-07-10 09:08:16 +02:00
vtemian
d8864bdf02 Added docs 2014-07-09 16:50:17 +03:00
vtemian
19dd7629d3 Proper naming 2014-07-09 16:46:52 +03:00
vtemian
02fd05baae Added clean_state_files 2014-07-09 16:39:34 +03:00
Carlos Martín Nieto
b1bacdd8d5 Wrap config snapshot functions
These allow complex reads to come from the same version of the config.
2014-05-18 11:03:30 +02:00
Carlos Martín Nieto
9309329b5a Merge pull request #361 from carlosmn/cffi-config
Config: move to cffi
2014-04-26 16:39:50 +02:00
Carlos Martín Nieto
c41c1a1c97 Config: move to cffi
This halves the amount of code we have to take into account for dealing
with the config.

There is a slight change in the API. Config.get_multivar() returns an
iterator instead of a list, which lets us reuse code from the general
iterator and is closer to libgit2's API.
2014-04-21 14:11:41 +02:00
J. David Ibáñez
d8bd6f73ab Merge remote-tracking branch 'kluyver/docstrings-update' 2014-04-19 11:38:21 +02:00
Thomas Kluyver
569d396f0d Use repo.head.target instead of repo.head.get_object().hex 2014-04-18 13:44:25 -07:00
Thomas Kluyver
37c01d79c5 Update some docstrings which had got out of date. 2014-04-17 10:13:26 -07:00
Carlos Martín Nieto
5a20510f8a Safer repository pointer extraction
Casting a pointer to a non-pointer type is something which you should
never do. Instead, do something a bit more convoluted, but which is
guaranteed to give us the right pointer, as well as making sure that the
memory we exchange between python/cffi and the C extension is of the
right pointer size.

While we're touching this code, fix which object we pass to the Remote
constructor to keep alive. We need to pass the Repository object to
stop it from becoming unreferenced (and thus freeing memory the remote
needs) instead of the git_repository pointer.
2014-04-16 22:12:54 +02:00
Carlos Martín Nieto
c76c3f0195 Start implementing remotes with CFFI
This moves enough code into python with CFFI to pass the test_remotes
unit tests. There is no credentials support yet.

There is a small change in the return value of Remote.fetch() in that we
now return a TransferProgress object instead of extracting a few values
into a dictionary.
2014-04-14 11:42:51 +02:00
Thomas Kluyver
af2528418a More informative repr for Repository objects 2014-03-25 15:13:10 -07:00
J. David Ibáñez
d7071b88cd Update copyright year 2014-02-04 08:02:12 +01:00
Daniel Rodríguez Troitiño
1062ab638b Implement Repository.lookup_branch. Constants for local and remote branches. 2013-05-26 17:43:28 +02:00
J. David Ibáñez
0c86307eb5 Coding style: Silent pep8 2013-05-26 14:39:12 +02:00
J. David Ibáñez
5904a8752c docs: fix warning 2013-05-24 23:10:55 +02:00
Nico von Geyso
6dd14d799e Fixed: Use GIT_DIFF_NORMAL as default flag for Diff 2013-05-20 15:38:49 +02:00
Nico von Geyso
86aafebb6d Fixed: remove OrderedDict for compability reasons (python2.6) 2013-05-20 15:13:04 +02:00
Nico von Geyso
77b5cdce5b Refactored: get rid of type check for treeish_to_tree in Diff 2013-05-20 14:58:54 +02:00
Nico von Geyso
6ce71a2799 Added: support for context_lines and interhunk_lines for diffs 2013-05-20 14:49:48 +02:00