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
//! What:
//! The copying of the real index into a private index: a copy that keeps the source's timestamps, the check of
//! whether the captured index may seed an explicit-path commit, and the failure that reports a copy which failed.
//! Why:
//! `commit_index.rs` initializes the private commit index for each selection mode and stays under the file-size
//! limit; the copy steps need nothing from it, so they live in a file of their own that it imports.
//!
//! In TS you'd write (pseudocode):
//! ```ts
//! await copyIndexFile({ sourcePath, destinationPath });
//! ```
/// The failure a step of the commit reports.
use crateGitFailure;
/// What marks the captured index carries.
use crate;
/// `FileTimes` carries the copied timestamps.
use FileTimes;
/// `Path` is a borrowed filesystem path.
use Path;
/// What:
/// Copies an index and gives the copy the source's access and modification times.
/// Why:
/// A copy with fresh times would make Git trust stat data captured in the same second
/// as a later same-size edit (issue #544).
/// A missing source is an error, as the incumbent's `copyFile` reports it.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// await copyIndexFile({ sourcePath, destinationPath });
/// ```
/// What:
/// Whether the captured real index may seed the private index of an explicit-path commit.
/// Why:
/// Only an index whose every entry was read and carries no assume-unchanged or skip-worktree mark may;
/// one that cannot be read is treated like a marked one, and the commit builds its index from the base alone.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// readIndexFlags(await readFile(capturedIndex).catch(() => undefined)) === 'plain'
/// ```
/// What:
/// The failure that reports an index file which could not be copied.
/// Why:
/// Three copies of `initialize_commit_index` report the same failure, and `map_err` takes this function by path
/// where a closure would otherwise stand.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// const copyIndexFailure = (error: Error) => new GitFailure(`copying the index failed: ${error}`);
/// ```