@@ -20,7 +20,29 @@ impl Mode {
20
20
}
21
21
22
22
/// Compares this mode to the file system version ([`std::fs::symlink_metadata`])
23
- /// and returns the change needed to update this mode to match the file if
23
+ /// and returns the change needed to update this mode to match the file.
24
+ ///
25
+ /// * if `has_symlinks` is false symlink entries will simply check if there
26
+ /// is a normal file on disk
27
+ /// * if `executable_bit` is false the executable bit will not be compared
28
+ /// `Change::ExecutableBit` will never be generated
29
+ ///
30
+ /// If there is a type change then we will use whatever information is
31
+ /// present on the FS. Specifically if `has_symlinks` is false we will
32
+ /// never generate `Change::TypeChange { new_mode: Mode::SYMLINK }`. and
33
+ /// iff `executable_bit` is false we will never generate `Change::TypeChange
34
+ /// { new_mode: Mode::FILE_EXECUTABLE }` (all files are assumed to be not
35
+ /// executable). That measn that unstaging and staging files can be a lossy
36
+ /// operation on such file systems.
37
+ ///
38
+ /// If a directory replaced a normal file/symlink we assume that the
39
+ /// directory is a submodule. Normal (non-submodule) direcotires would
40
+ /// cause a file to be deleted from the index and should be handled before
41
+ /// calling this function.
42
+ ///
43
+ /// If the stat information belongs to something other than a normal file/
44
+ /// directory (like a socket) we just return an identity change (non-files
45
+ /// can not be committed to git)
24
46
pub fn change_to_match_fs (
25
47
self ,
26
48
stat : & std:: fs:: Metadata ,
@@ -37,7 +59,7 @@ impl Mode {
37
59
_ => return None ,
38
60
} ;
39
61
let new_mode = if stat. is_dir ( ) {
40
- Mode :: DIR
62
+ Mode :: COMMIT
41
63
} else if executable_bit && is_executable ( stat) {
42
64
Mode :: FILE_EXECUTABLE
43
65
} else {
0 commit comments