Reimplementation of Pijul in C, for education, fun and absolutely no profit
ani
===

Pijul, written in C. I do this to gain a thorough understanding of Pijul's
internals and the way patches are represented and worked with. A secondary,
distant goal is to create an alternate implementation that could act as a
point of comparison to the Rust implementation.

## Dependencies

To build you need a compiler for C11, the [meson build
system](https://mesonbuild.com/) and
[ninja]https://ninja-build.org/. ([muon]https://muon.build/ and
[samurai]https://github.com/michaelforney/samurai might also work.)

The following libraries should be available (as shared libraries):

 * [zstd]https://facebook.github.io/zstd/ for compression/decompression
 * [xxhash]https://cyan4973.github.io/xxHash/ (used by zstd)

These dependencies are vendored (in the `vendor` directory):

 * [blake3]https://github.com/BLAKE3-team/BLAKE3/tree/master/c for hashes
 * [zstd
   seekable](https://github.com/facebook/zstd/blob/dev/contrib/seekable_format/zstd_seekable_compression_format.md)
   a seekable variant of zstd

## Build

Initially, run `make setup` to create the build directory.

Run `make` to build the project.

To run tests, run `make check`.

## Code style

Fundamental rules:

 * No header file includes another header file (vendored dependencies
   are exempted from this)
 * Formatted with clang-format - execute `make fmt` to get formatting right

### Header files

Simple rule: include files should never include include files (see
[pikestyle][pikestyle]). Instead they state (in comments or implicitly)
what files they need to have included first, the problem of deciding which
files to include is pushed to the user. (vendored header files are exempted
from this rule to make it easier to update a vendored dependency.)

[pikestyle]: http://doc.cat-v.org/bell_labs/pikestyle

In addition, system include files should be grouped first before any user
include files, and the first user include file _must_ be common.h. All .c
files in this project _must_ include common.h As an example, this is the
correct way to include files:

    #include <stdlib.h>
    #include <stdint.h>
    #include <stdio.h>

    #include "common.h"
    #include "atom.h"

Prefer to leave a blank line in between the system includes and user includes.

### Type declarations

Use typedef sparingly, only for creating an alias for a type. Structs
should not be typedef'd, instead we use the `struct` keyword. Names
should be lowercase, preferably without underscores.

A correct declaration looks as follows:

    struct changeheader {
        ...
    };

## Mirrored to git

There is a git mirror maintained on
<https://git.sr.ht/~laumann/ani>. This mirror is maintained using
[andybalhom/pijul-export]https://nest.pijul.com/andybalholm/pijul-export.

Use the following command to update the git mirror:

    $ pijul-export --repo <ani-path> --marks pijul-marks | git fast-import --import-marks=git-marks --export-marks=git-marks

## Links

 * getopt(3p): <https://portal.mozz.us/gemini/laumann.srht.site/c/getopt.gmi>
 * <https://pijul.org/manual/>
 * `stdint.h(0p)` - for uint64_t types, etc