File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,24 @@ mod access {
14
14
pub fn to_easy ( & self ) -> easy:: Handle {
15
15
self . into ( )
16
16
}
17
+
18
+ // TODO: tests
19
+ /// Load the index file of this repository's workspace, if present.
20
+ ///
21
+ /// Note that it is loaded into memory each time this method is called, but also is independent of the workspace.
22
+ pub fn load_index ( & self ) -> Option < Result < git_index:: File , git_index:: file:: init:: Error > > {
23
+ // TODO: choose better/correct options
24
+ let opts = git_index:: decode:: Options {
25
+ object_hash : self . object_hash ,
26
+ thread_limit : None ,
27
+ min_extension_block_in_bytes_for_threading : 1024 * 256 ,
28
+ } ;
29
+ match git_index:: File :: at ( self . git_dir ( ) . join ( "index" ) , opts) {
30
+ Ok ( index) => Some ( Ok ( index) ) ,
31
+ Err ( git_index:: file:: init:: Error :: Io ( err) ) if err. kind ( ) == std:: io:: ErrorKind :: NotFound => None ,
32
+ Err ( err) => Some ( Err ( err) ) ,
33
+ }
34
+ }
17
35
}
18
36
}
19
37
You can’t perform that action at this time.
0 commit comments