Skip to content

Commit

Permalink
Provide example for Reference.log_append
Browse files Browse the repository at this point in the history
I would have found this useful when trying to do reflog additions. It
might not be massively complex but examples always help.
  • Loading branch information
michaeljones committed Jun 15, 2014
1 parent 7296b92 commit 1f111c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ The Reference type
.. automethod:: pygit2.Reference.resolve
.. automethod:: pygit2.Reference.log
.. automethod:: pygit2.Reference.log_append

Example::

>>> branch = repository.lookup_reference("refs/heads/master")
>>> branch.target = another_commit.id
>>> committer = Signature('Cecil Committer', 'cecil@committers.tld')
>>> branch.log_append(another_commit.id, committer,
"changed branch target using pygit2")

This creates a reflog entry in ``git reflog master`` which looks like::

7296b92 master@{10}: changed branch target using pygit2

In order to make an entry in ``git reflog``, ie. the reflog for ``HEAD``, you
have to get the Reference object for ``HEAD`` and call ``log_append`` on
that.

.. automethod:: pygit2.Reference.get_object


Expand Down

0 comments on commit 1f111c0

Please sign in to comment.