Skip to content

Commit effa0cf

Browse files
committed
Add check_stat and trust_ctime options to index checkout (#301)
For now they are unused but that should change when doing collision checks.
1 parent b1bddad commit effa0cf

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

git-worktree/src/index.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@ pub mod checkout {
44
use bstr::BString;
55
use quick_error::quick_error;
66

7-
#[derive(Default, Clone, Copy)]
7+
#[derive(Clone, Copy)]
88
pub struct Options {
99
/// capabilities of the file system
1010
pub fs: crate::fs::Capabilities,
1111
/// If true, we assume no file to exist in the target directory, and want exclusive access to it.
1212
/// This should be enabled when cloning.
1313
pub destination_is_initially_empty: bool,
14+
/// If true, a files creation time is taken into consideration when checking if a file changed.
15+
/// Can be set to false in case other tools alter the creation time in ways that interfere with our operation.
16+
///
17+
/// Default true.
18+
pub trust_ctime: bool,
19+
/// If true, all stat fields will be used when checking for up-to-date'ness of the entry. Otherwise
20+
/// nano-second parts of mtime and ctime,uid, gid, inode and device number won't be used, leaving only
21+
/// the whole-second part of ctime and mtime and the file size to be checked.
22+
///
23+
/// Default true.
24+
pub check_stat: bool,
25+
}
26+
27+
impl Default for Options {
28+
fn default() -> Self {
29+
Options {
30+
fs: Default::default(),
31+
destination_is_initially_empty: false,
32+
trust_ctime: true,
33+
check_stat: true,
34+
}
35+
}
1436
}
1537

1638
quick_error! {

git-worktree/tests/index/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ mod checkout {
2727
..Default::default()
2828
},
2929
destination_is_initially_empty: true,
30+
..Default::default()
3031
}
3132
}
3233

0 commit comments

Comments
 (0)