File: git-log.rst

package info (click to toggle)
python-pygit2 1.4.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,328 kB
  • sloc: ansic: 11,016; python: 5,943; sh: 275; makefile: 19
file content (47 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
**********************************************************************
git-log
**********************************************************************

----------------------------------------------------------------------
Showing HEAD commit logs
----------------------------------------------------------------------

======================================================================
Show HEAD commit
======================================================================

.. code-block:: bash

    $ git log -1

.. code-block:: python

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

======================================================================
Traverse commit history
======================================================================

.. code-block:: bash

    $ git log

.. code-block:: python

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

----------------------------------------------------------------------
References
----------------------------------------------------------------------

- git-log_.

- `libgit2 discussion about walker behavior
  <https://github.com/libgit2/libgit2/issues/3041>`_. Note that the libgit2's
  walker functions differently than ``git-log`` in some ways.

.. _git-log: https://www.kernel.org/pub/software/scm/git/docs/git-log.html