Project Nayuki


Git library (Java)

This library reads and writes raw objects in a Git repository, giving a high degree of visibility and control to the application developer. The library is implemented in pure Java with no dependencies on tools or libraries, and is based on my own understanding of Git’s low-level storage format.

The library focuses on directly manipulating file data (blobs, trees) and history (commits). It does not deal with the working copy, index / staging area, or network communication.

Project source code at GitHub: https://github.com/nayuki/Git-library-Java

Supported features:

Unsupported features:

The list of unsupported features does not cover every conceivably wanted feature. However, the list can shrink as features get implemented.

Examples

ShowCommitGraphInfo

Starts at the given branches (such as master), scans the entire history of ancestor commits, and prints a number of statistics about the commit graph:

  • Number of root commits (which have zero parents)
  • Number of fork commits (which have more than one child)
  • Number of merge commits (which have more than one parent)
  • Longest chain of commits (maximum number of commits encountered when starting at some commit and iteratively following a parent pointer)
  • Total number of commits (number of commits reachable from the starting points)
ListAllHistoricalFilePaths

Starts at the master branch, scans the entire history of ancestor commits, scans the complete file tree of each commit, and prints a list representing the union of all paths ever used. For example if a file was located at /foo/x.cpp in one version and was moved to /bar/y.cpp in the next version, then both paths will be printed by this program.