1
1
use std:: { ffi:: OsString , path:: PathBuf } ;
2
2
3
3
use anyhow:: bail;
4
- use gix:: prelude:: FindExt ;
5
4
6
5
pub fn from_tree (
6
+ repo : gix:: Repository ,
7
7
mut spec : OsString ,
8
8
index_path : Option < PathBuf > ,
9
9
force : bool ,
10
- repo : gix :: Repository ,
10
+ skip_hash : bool ,
11
11
) -> anyhow:: Result < ( ) > {
12
12
spec. push ( "^{tree}" ) ;
13
13
let spec = gix:: path:: os_str_into_bstr ( & spec) ?;
14
14
let tree = repo. rev_parse_single ( spec) ?;
15
- let index = gix:: index:: State :: from_tree ( & tree, |oid, buf| repo. objects . find_tree_iter ( oid, buf) . ok ( ) ) ?;
16
- let options = gix:: index:: write:: Options :: default ( ) ;
15
+
16
+ let mut index = repo. index_from_tree ( & tree) ?;
17
+ let options = gix:: index:: write:: Options {
18
+ skip_hash,
19
+ ..Default :: default ( )
20
+ } ;
17
21
18
22
match index_path {
19
23
Some ( index_path) => {
@@ -23,11 +27,10 @@ pub fn from_tree(
23
27
index_path. display( )
24
28
) ;
25
29
}
26
- let mut index = gix :: index :: File :: from_state ( index , index_path) ;
30
+ index. set_path ( index_path) ;
27
31
index. write ( options) ?;
28
32
}
29
33
None => {
30
- let index = gix:: index:: File :: from_state ( index, std:: path:: PathBuf :: new ( ) ) ;
31
34
let mut out = Vec :: with_capacity ( 512 * 1024 ) ;
32
35
index. write_to ( & mut out, options) ?;
33
36
}
@@ -36,7 +39,12 @@ pub fn from_tree(
36
39
Ok ( ( ) )
37
40
}
38
41
39
- pub fn from_list ( entries_file : PathBuf , index_path : Option < PathBuf > , force : bool ) -> anyhow:: Result < ( ) > {
42
+ pub fn from_list (
43
+ entries_file : PathBuf ,
44
+ index_path : Option < PathBuf > ,
45
+ force : bool ,
46
+ skip_hash : bool ,
47
+ ) -> anyhow:: Result < ( ) > {
40
48
use std:: io:: BufRead ;
41
49
let object_hash = gix:: hash:: Kind :: Sha1 ;
42
50
@@ -57,7 +65,10 @@ pub fn from_list(entries_file: PathBuf, index_path: Option<PathBuf>, force: bool
57
65
}
58
66
index. sort_entries ( ) ;
59
67
60
- let options = gix:: index:: write:: Options :: default ( ) ;
68
+ let options = gix:: index:: write:: Options {
69
+ skip_hash,
70
+ ..Default :: default ( )
71
+ } ;
61
72
match index_path {
62
73
Some ( index_path) => {
63
74
if index_path. is_file ( ) && !force {
0 commit comments