Skip to content

Commit eddead7

Browse files
committed
sketch filesystem context, without probing for now (#301)
1 parent 6946300 commit eddead7

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

git-worktree/src/lib.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
11
#![forbid(unsafe_code, rust_2018_idioms)]
22

3+
/// file system related utilities
4+
pub mod fs {
5+
/// Common knowledge about the worktree that is needed across most interactions with the work tree
6+
pub struct Context {
7+
/// If true, the filesystem will store paths as decomposed unicode, i.e. `ä` becomes `"a\u{308}"`, which means that
8+
/// we have to turn these forms back from decomposed to precomposed unicode before storing it in the index or generally
9+
/// using it. This also applies to input received from the command-line, so callers may have to be aware of this and
10+
/// perform conversions accordingly.
11+
/// If false, no conversions will be performed.
12+
pub precompose_unicode: bool,
13+
/// If true, the filesystem ignores the case of input, which makes `A` the same file as `a`.
14+
/// This is also called case-folding.
15+
pub ignore_case: bool,
16+
/// If true, we assume the the executable bit is honored as part of the files mode. If false, we assume the file system
17+
/// ignores the executable bit, hence it will be reported as 'off' even though we just tried to set it to be on.
18+
pub file_mode: bool,
19+
/// If true, the file system supports symbolic links and we should try to create them. Otherwise symbolic links will be checked
20+
/// out as files which contain the link as text.
21+
pub symlink: bool,
22+
}
23+
24+
#[cfg(windows)]
25+
impl Default for Context {
26+
fn default() -> Self {
27+
Context {
28+
precompose_unicode: false,
29+
ignore_case: true,
30+
file_mode: false,
31+
symlink: false,
32+
}
33+
}
34+
}
35+
36+
#[cfg(target_os = "macos")]
37+
impl Default for Context {
38+
fn default() -> Self {
39+
Context {
40+
precompose_unicode: true,
41+
ignore_case: true,
42+
file_mode: true,
43+
symlink: true,
44+
}
45+
}
46+
}
47+
48+
#[cfg(all(unix, not(target_os = "macos")))]
49+
impl Default for Context {
50+
fn default() -> Self {
51+
Context {
52+
precompose_unicode: false,
53+
ignore_case: false,
54+
file_mode: true,
55+
symlink: true,
56+
}
57+
}
58+
}
59+
}
60+
361
pub mod index;

0 commit comments

Comments
 (0)