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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! A crate with file-system specific utilities.
//!
//! ## Examples
//!
//! ```
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use std::path::{Path, PathBuf};
//!
//! use gix_fs::{
//! stack::{Delegate, ToNormalPathComponents},
//! Stack,
//! };
//!
//! let components = "src/lib.rs"
//! .to_normal_path_components()
//! .collect::<Result<Vec<_>, _>>()
//! .map_err(|err| err.into_error())?;
//! assert_eq!(
//! components
//! .into_iter()
//! .map(|component| component.to_string_lossy().into_owned())
//! .collect::<Vec<_>>(),
//! vec!["src", "lib.rs"]
//! );
//!
//! #[derive(Default)]
//! struct Recorder {
//! directories: Vec<PathBuf>,
//! paths: Vec<PathBuf>,
//! }
//!
//! impl Delegate for Recorder {
//! fn push_directory(&mut self, stack: &Stack) -> std::io::Result<()> {
//! self.directories.push(stack.current_relative().to_path_buf());
//! Ok(())
//! }
//!
//! fn push(&mut self, _is_last_component: bool, stack: &Stack) -> std::io::Result<()> {
//! self.paths.push(stack.current_relative().to_path_buf());
//! Ok(())
//! }
//!
//! fn pop_directory(&mut self) {}
//! }
//!
//! # let dir = tempfile::tempdir()?;
//! let capabilities = gix_fs::Capabilities::probe_dir(dir.path());
//! let mut stack = Stack::new(dir.path().to_path_buf());
//! let mut recorder = Recorder::default();
//! stack.make_relative_path_current("src/lib.rs", &mut recorder)?;
//!
//! assert_eq!(stack.current_relative(), Path::new("src/lib.rs"));
//! assert_eq!(recorder.directories[0], Path::new(""));
//! assert_eq!(recorder.paths, vec![PathBuf::from("src"), PathBuf::from("src/lib.rs")]);
//! assert_eq!(gix_fs::current_dir(capabilities.precompose_unicode)?, std::env::current_dir()?);
//! # Ok(()) }
//! ```
use PathBuf;
/// Common knowledge about the worktree that is needed across most interactions with the work tree
pub use ;
///
///
pub use read_dir;
///
/// Like [`std::env::current_dir()`], but it will `precompose_unicode` if that value is true, if the current directory
/// is valid unicode and if there are decomposed unicode codepoints.
///
/// Thus, it will turn `"a\u{308}"` into `ä` if `true`.
/// Keeping it `false` will not alter the output.
///
/// Note that `precompose_unicode` most be set using the `core.precomposeUnicode` git configuration.
/// Adjust `permissions` according to Git's shared-repository permission policy.
///
/// `permissions` should normally be the permissions of a newly created file, read back after the operating system has
/// applied the process umask. Apply this function before the file is made visible at its final path. Existing permission
/// bits not governed by the policy are preserved.
///
/// `shared_repository_permissions` uses Git's compact signed encoding and usually comes from parsing the effective
/// `core.sharedRepository` configuration value:
///
/// - `0` leaves the permissions produced by the umask unchanged. An absent key, `umask`, boolean `false`, and legacy
/// value `0` produce this.
/// - A positive mode is ORed into the post-umask mode. A bare key, `group`, boolean `true`, and legacy value `1` usually
/// produce `0o660`; `all`, `world`, `everybody`, and legacy value `2` usually produce `0o664`.
/// - A negative mode replaces the low nine Unix permission bits with its absolute value. Git-compatible parsers use this
/// for explicit octal configuration such as `0640`, represented here as `-0o640`, so it can remove bits allowed by the
/// umask instead of merely adding bits.
///
/// Callers must pass the parsed encoding, not an explicit octal configuration value directly. On non-Unix platforms the
/// shared-repository mode has no portable representation in [`std::fs::Permissions`], so this function returns
/// `permissions` unchanged.
/// A stack of path components with the delegation of side-effects as the currently set path changes, component by component.
/// Returns whether a file has the executable permission set.
/// Classifiers for IO-errors.
/// Returns whether a file has the executable permission set.
///