git-in-haskell-from-the-bottom-up /

Filename Size Date modified Message
59 B
13 B
1.5 KB
1.8 KB
808 B
47 B
2.8 KB

Implementing git clone in Haskell

Source code for the git clone in Haskell from the bottom up article.

The hgit executable created by this cabal package supports a very limited number of operations, most notably the clone command:

hgit clone git://

Apart from clone the following commands are supported:

  • ls-remote: Because it's already implemented as part of the clone operation
  • unpack: Unpack a raw pack file (whithout the need to have an index file for the pack) into a git repository
  • read-index: Similar to git ls-files --debug this shows the information in the git index file (expects a path to the index file though and is not required to be executed within the git repository).

    [4766] λ > hgit read-index .git/index .ghci .ghci ctime: 1363781495 mtime: 1363781495 dev: 16777220 inode: 9756391 uid: 501 gid: 20 size: 59 git file mode: Regular sha1: c364d6f7508e2f6d1607a9d73e6330d68ec7d62a


To build the binary run

cabal configure
cabal build

If any of the dependencies are missing run:

cabal install --only-dependencies

To copy it into the cabal bin directory that should be in the $PATH, run

cabal copy

There is a simple Rakefile that can be used to build the binary and to run the test suite:

[4832] λ > rake -T
rake build     # Build the hgit binary
rake clean     # Clean artifacts
rake deps      # Install required dependencies
rake dev:tags  # Generate a ctags file
rake test      # Run the tests


To run the tests directly run:

cabal clean
cabal configure --enable-tests
cabal build
cabal test --show-details=always
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.