Skip to content
zit Artifact [d94c691c2a]
Login

Artifact [d94c691c2a]

Artifact d94c691c2a7271613567b517ce9b4709019186bc98a8287b23422133ed795195:


# zit 0.3.40

zit 0.3.40 puts line counts in the crosslink stream. A forge can show
"+15 −3" on every check-in and file without running `zit diff --numstat`
once per check-in.

No artifact, tag namespace, wire, or on-disk repository format changed. The
crosslink record format is still `crosslink 1`.

## Line counts in the crosslink stream

Each `file` line in `zit crosslink` is now followed by a line giving what the
file added and removed against the primary parent:

```
file M src/a.zig
lines 12 3
file A src/b.zig
lines 40 0
file M logo.png
lines - -
```

- The counts are the ones `zit diff --numstat --checkin` gives for the same
  path. Both commands now count with one function, so they cannot disagree.
- A binary file is `- -`.
- A file whose mode alone changed is `0 0`. `--numstat` leaves such a file
  out, because its text did not change.
- An add counts every line as added; a delete counts every line as removed.
- When the store cannot produce a file's content on either side, because the
  content was shunned or never fetched into a sparse store, there is no
  `lines` line for that file. Its counts appear once the content arrives.
- `files unknown` records carry no `lines` lines.

A consumer that parses only the lines it knows is unaffected: the stream has
always promised that a consumer skips a line it does not know.

## What it costs

Counting reads both sides of every changed file, so it is kept away from
everything else:

- The counts live in a cache file of their own, `.zit-cache/lines`, that only
  `crosslink` reads or writes. The cache every other command builds on its
  first open is unchanged, and so is the time it takes.
- The first `crosslink` over a long history counts every change once, and
  takes longer than it used to. Later runs read the stored counts and count
  only new check-ins. A first run that is cut short keeps what it counted
  and resumes from there.
- A check-in's counts never change once its name is known, so growth of the
  repository never invalidates them; a shun discards them, since it removes
  content they were read from.
- `--no-cache` counts everything afresh and stores nothing, so its output can
  still be compared byte for byte with the cached run.

## Compatibility

- `zit diff --numstat` prints exactly what it printed before.
- Existing `crosslink` lines are unchanged in content and order; the `lines`
  lines are the only addition.

## Qualification

`zig fmt --check`, `zig build test`, `e2e`, `smoke` (19 scenarios),
`git-import-e2e`, `git-export-e2e`, `dst`, and every fuzz target, plus the
three-runner battery.