File tree 2 files changed +17
-11
lines changed
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -87,13 +87,27 @@ impl Transaction {
87
87
) )
88
88
}
89
89
90
+ pub fn open_from_env ( load_cache : bool ) -> JoshResult < Transaction > {
91
+ let repo = git2:: Repository :: open_from_env ( ) ?;
92
+ let path = repo. path ( ) . to_owned ( ) ;
93
+ if load_cache {
94
+ load ( & path) ?
95
+ } ;
96
+
97
+ Ok ( Transaction :: new (
98
+ repo,
99
+ gix:: ThreadSafeRepository :: open ( path) ?. to_thread_local ( ) ,
100
+ None ,
101
+ ) )
102
+ }
103
+
90
104
pub fn status ( & self , _msg : & str ) {
91
105
/* let mut t2 = self.t2.borrow_mut(); */
92
106
/* write!(t2.out, "{}", msg).ok(); */
93
107
/* t2.out.flush().ok(); */
94
108
}
95
109
96
- pub fn new (
110
+ fn new (
97
111
repo : git2:: Repository ,
98
112
oxide_repo : gix:: Repository ,
99
113
ref_prefix : Option < & str > ,
Original file line number Diff line number Diff line change @@ -147,15 +147,9 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
147
147
148
148
let mut filterobj = josh:: filter:: parse ( & specstr) ?;
149
149
150
- let repo = git2:: Repository :: open_from_env ( ) ?;
151
- if !args. get_flag ( "no-cache" ) {
152
- josh:: cache:: load ( repo. path ( ) ) ?;
153
- }
150
+ let transaction = josh:: cache:: Transaction :: open_from_env ( !args. get_flag ( "no-cache" ) ) ?;
154
151
155
- let oxide_repo = gix:: ThreadSafeRepository :: open ( repo. path ( ) ) ?;
156
- let transaction = josh:: cache:: Transaction :: new ( repo, oxide_repo. to_thread_local ( ) , None ) ;
157
152
let repo = transaction. repo ( ) ;
158
-
159
153
let input_ref = args. get_one :: < String > ( "input" ) . unwrap ( ) ;
160
154
161
155
let mut refs = vec ! [ ] ;
@@ -418,9 +412,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
418
412
std:: mem:: drop ( finish) ;
419
413
420
414
if let Some ( query) = args. get_one :: < String > ( "query" ) {
421
- let repo = git2:: Repository :: open_from_env ( ) ?;
422
- let oxide_repo = gix:: ThreadSafeRepository :: open ( repo. path ( ) ) ?;
423
- let transaction = josh:: cache:: Transaction :: new ( repo, oxide_repo. to_thread_local ( ) , None ) ;
415
+ let transaction = josh:: cache:: Transaction :: open_from_env ( false ) ?;
424
416
let commit_id = transaction. repo ( ) . refname_to_id ( update_target) ?;
425
417
print ! (
426
418
"{}" ,
You can’t perform that action at this time.
0 commit comments