@@ -176,15 +176,14 @@ fn do_rebase_inner(
176
176
Ok ( ( ) )
177
177
}
178
178
179
- struct RepoBranches < ' a > ( HashMap < Oid , Branch < ' a > > ) ;
179
+ struct RepoBranches < ' a > ( HashMap < Oid , Vec < Branch < ' a > > > ) ;
180
180
181
181
impl < ' a > RepoBranches < ' a > {
182
182
fn for_repo ( repo : & ' a Repository ) -> Result < RepoBranches < ' a > , anyhow:: Error > {
183
- let mut branches: HashMap < Oid , Branch > = HashMap :: new ( ) ;
183
+ let mut branches: HashMap < Oid , Vec < Branch > > = HashMap :: new ( ) ;
184
184
for ( branch, _type) in repo. branches ( Some ( git2:: BranchType :: Local ) ) ?. flatten ( ) {
185
185
let oid = branch. get ( ) . peel_to_commit ( ) ?. id ( ) ;
186
- // TODO: handle multiple branches pointing to the same commit
187
- branches. insert ( oid, branch) ;
186
+ branches. entry ( oid) . or_default ( ) . push ( branch) ;
188
187
}
189
188
Ok ( RepoBranches ( branches) )
190
189
}
@@ -196,13 +195,14 @@ impl<'a> RepoBranches<'a> {
196
195
target_commit : Oid ,
197
196
rebase : & mut Rebase < ' _ > ,
198
197
) -> Result < ( ) , anyhow:: Error > {
199
- if let Some ( branch ) = self . 0 . get_mut ( & original_commit) {
198
+ if let Some ( branches ) = self . 0 . get_mut ( & original_commit) {
200
199
// Don't retarget the last branch, rebase.finish does that for us
201
- // TODO: handle multiple branches
202
200
if rebase. operation_current ( ) != Some ( rebase. len ( ) - 1 ) {
203
- branch
204
- . get_mut ( )
205
- . set_target ( target_commit, "git-instafix retarget historical branch" ) ?;
201
+ for branch in branches. iter_mut ( ) {
202
+ branch
203
+ . get_mut ( )
204
+ . set_target ( target_commit, "git-instafix retarget historical branch" ) ?;
205
+ }
206
206
}
207
207
}
208
208
Ok ( ( ) )
0 commit comments