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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// githttp-fs
//
// Git-based Content Management System
// Copyright: 2026, Valerian Saliou <valerian@valeriansaliou.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
//! The per-directory file-dates index: its reserved path and its stored
//! format.
//!
//! A file's creation and last-change dates are facts of its commit history,
//! but git keeps no index from a path to the commits that touched it, so
//! deriving them means walking history — a cost that grows with the
//! repository rather than with the request, and that no bound makes O(1).
//! They are therefore **recorded when they happen**: every commit this server
//! makes stamps the dates of the files it changed into the `.dates.json` of
//! their directory, in that same commit, and a read is one small blob read.
//!
//! It mirrors the file-order index (`order.rs`) wherever it can — what the
//! two share lives in `reserved.rs` — for the same
//! reasons: stored **per directory**, keyed by **leaf name**, so a commit
//! touches one small file per directory it changed, and a folder move carries
//! its indexes along with its subtree. What differs is ownership. The order
//! index is the caller's data, written through its own route and announced
//! by its own events; the dates index is the server's bookkeeping, written
//! only as a side effect of commits, never addressable, never announced, and
//! left out of every view of a commit (see `GitDates::stamp` in `git.rs`).
//!
//! Two rules keep it honest:
//!
//! - **Absence means unknown.** A file with no entry — one last written
//! before the index existed, or committed by anything other than this
//! server — reads as `null` dates, never as a guessed value. Likewise an
//! entry's `created_at` is `null` when the file already existed, unindexed,
//! at the time its first indexed change was recorded.
//! - **Malformed means absent.** Only this server writes the file, so a
//! broken one can only come from a hand-edited commit, and that must not
//! turn a read into an error.
use BTreeMap;
use ;
use ;
use cratereserved;
/// Reserved leaf name of the dates index. Dot-prefixed like the order index,
/// and filtered out of every `/files` route regardless of
/// `include_hidden_files`.
pub const DATES_FILE_NAME: &str = ".dates.json";
/// One file's recorded dates. `created_at` is `None` when the file's creation
/// predates the index (see the module documentation).
/// A directory's index: leaf name to dates. A `BTreeMap` so the stored
/// document is name-sorted, which keeps the blob deterministic and its git
/// diffs minimal.
pub type DatesIndex = ;
/// The stored document, deserialising side. An object rather than a bare
/// map so other server-recorded metadata can join it without a format
/// version bump.
/// The stored document, serialising side — borrows the index rather than
/// cloning it on every commit.
/// Repo-root-relative path of the index for `directory` (`""` being the
/// repository root).
/// Whether `path` names a dates index, at any depth.
/// Serialises an index into the stored document, pretty-printed with a
/// trailing newline like the order index.
/// Parses a stored document, or `None` when it cannot be read as one.