]> git.proxmox.com Git - rustc.git/blob - vendor/gix-worktree/src/checkout/mod.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / vendor / gix-worktree / src / checkout / mod.rs
1 #![allow(missing_docs)]
2
3 use bstr::BString;
4 use gix_index::entry::stat;
5
6 #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
7 pub struct Collision {
8 /// the path that collided with something already present on disk.
9 pub path: BString,
10 /// The io error we encountered when checking out `path`.
11 pub error_kind: std::io::ErrorKind,
12 }
13
14 pub struct ErrorRecord {
15 /// the path that encountered the error.
16 pub path: BString,
17 /// The error
18 pub error: Box<dyn std::error::Error + Send + Sync + 'static>,
19 }
20
21 #[derive(Default)]
22 pub struct Outcome {
23 /// The amount of files updated, or created.
24 pub files_updated: usize,
25 /// The amount of bytes written to disk,
26 pub bytes_written: u64,
27 pub collisions: Vec<Collision>,
28 pub errors: Vec<ErrorRecord>,
29 }
30
31 #[derive(Clone, Default)]
32 pub struct Options {
33 /// capabilities of the file system
34 pub fs: gix_fs::Capabilities,
35 /// If set, don't use more than this amount of threads.
36 /// Otherwise, usually use as many threads as there are logical cores.
37 /// A value of 0 is interpreted as no-limit
38 pub thread_limit: Option<usize>,
39 /// If true, we assume no file to exist in the target directory, and want exclusive access to it.
40 /// This should be enabled when cloning to avoid checks for freshness of files. This also enables
41 /// detection of collisions based on whether or not exclusive file creation succeeds or fails.
42 pub destination_is_initially_empty: bool,
43 /// If true, default false, worktree entries on disk will be overwritten with content from the index
44 /// even if they appear to be changed. When creating directories that clash with existing worktree entries,
45 /// these will try to delete the existing entry.
46 /// This is similar in behaviour as `git checkout --force`.
47 pub overwrite_existing: bool,
48 /// If true, default false, try to checkout as much as possible and don't abort on first error which isn't
49 /// due to a conflict.
50 /// The checkout operation will never fail, but count the encountered errors instead along with their paths.
51 pub keep_going: bool,
52 /// Control how stat comparisons are made when checking if a file is fresh.
53 pub stat_options: stat::Options,
54 /// A stack of attributes to use with the filesystem cache to use as driver for filters.
55 pub attributes: crate::cache::state::Attributes,
56 }
57
58 #[derive(Debug, thiserror::Error)]
59 pub enum Error<E: std::error::Error + Send + Sync + 'static> {
60 #[error("Could not convert path to UTF8: {}", .path)]
61 IllformedUtf8 { path: BString },
62 #[error("The clock was off when reading file related metadata after updating a file on disk")]
63 Time(#[from] std::time::SystemTimeError),
64 #[error("IO error while writing blob or reading file metadata or changing filetype")]
65 Io(#[from] std::io::Error),
66 #[error("object {} for checkout at {} could not be retrieved from object database", .oid.to_hex(), .path.display())]
67 Find {
68 #[source]
69 err: E,
70 oid: gix_hash::ObjectId,
71 path: std::path::PathBuf,
72 },
73 }
74
75 mod chunk;
76 mod entry;
77 pub(crate) mod function;