27
27
/// Note that this doesn't fetch the objects mentioned in the tips nor does it make any change to underlying repository.
28
28
#[ git_protocol:: maybe_async:: maybe_async]
29
29
pub async fn list_refs ( mut self ) -> Result < Vec < git_protocol:: fetch:: Ref > , Error > {
30
- let res = self . fetch_refs ( ) . await ? ;
30
+ let res = self . fetch_refs ( ) . await ;
31
31
git_protocol:: fetch:: indicate_end_of_interaction ( & mut self . transport ) . await ?;
32
- Ok ( res. refs )
32
+ Ok ( res? . refs )
33
33
}
34
34
35
35
#[ git_protocol:: maybe_async:: maybe_async]
@@ -99,19 +99,19 @@ pub mod to_map {
99
99
/// Note that this doesn't fetch the objects mentioned in the tips nor does it make any change to underlying repository.
100
100
#[ git_protocol:: maybe_async:: maybe_async]
101
101
pub async fn list_refs_to_map ( mut self ) -> Result < fetch:: RefMap , Error > {
102
- let mappings = self . ref_map ( ) . await ? ;
102
+ let res = self . ref_map ( ) . await ;
103
103
git_protocol:: fetch:: indicate_end_of_interaction ( & mut self . transport )
104
104
. await
105
105
. map_err ( |err| Error :: ListRefs ( crate :: remote:: list_refs:: Error :: Transport ( err) ) ) ?;
106
- Ok ( mappings )
106
+ Ok ( res? )
107
107
}
108
108
109
109
#[ git_protocol:: maybe_async:: maybe_async]
110
110
async fn ref_map ( & mut self ) -> Result < fetch:: RefMap , Error > {
111
- let res = self . fetch_refs ( ) . await ?;
111
+ let remote = self . fetch_refs ( ) . await ?;
112
112
let group = git_refspec:: MatchGroup :: from_fetch_specs ( self . remote . fetch_specs . iter ( ) . map ( |s| s. to_ref ( ) ) ) ;
113
- let ( _res , fixes) = group
114
- . match_remotes ( res . refs . iter ( ) . map ( |r| {
113
+ let ( res , fixes) = group
114
+ . match_remotes ( remote . refs . iter ( ) . map ( |r| {
115
115
let ( full_ref_name, target, object) = r. unpack ( ) ;
116
116
git_refspec:: match_group:: Item {
117
117
full_ref_name,
@@ -120,10 +120,23 @@ pub mod to_map {
120
120
}
121
121
} ) )
122
122
. validated ( ) ?;
123
- Ok ( fetch:: RefMap {
124
- mappings : Vec :: new ( ) ,
125
- fixes,
126
- } )
123
+ let mappings = res. mappings ;
124
+ let mappings = mappings
125
+ . into_iter ( )
126
+ . map ( |m| fetch:: Mapping {
127
+ remote : m
128
+ . item_index
129
+ . map ( |idx| fetch:: Source :: Ref ( remote. refs [ idx] . clone ( ) ) )
130
+ . unwrap_or_else ( || {
131
+ fetch:: Source :: ObjectId ( match m. lhs {
132
+ git_refspec:: match_group:: SourceRef :: ObjectId ( id) => id,
133
+ _ => unreachable ! ( "no item index implies having an object id" ) ,
134
+ } )
135
+ } ) ,
136
+ local : m. rhs . map ( |c| c. into_owned ( ) ) ,
137
+ } )
138
+ . collect ( ) ;
139
+ Ok ( fetch:: RefMap { mappings, fixes } )
127
140
}
128
141
}
129
142
}
0 commit comments