File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
crates/gitbutler-stack/src Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -258,9 +258,19 @@ impl StackBranch {
258258 }
259259
260260 pub fn head_oid ( & self , repo : & gix:: Repository ) -> Result < git2:: Oid > {
261- let mut reference = repo. find_reference ( & self . name ) ?;
262- let commit = reference. peel_to_commit ( ) ?;
263- Ok ( commit. id . to_git2 ( ) )
261+ if let Some ( mut reference) = repo. try_find_reference ( & self . name ) ? {
262+ let commit = reference. peel_to_commit ( ) ?;
263+ Ok ( commit. id . to_git2 ( ) )
264+ } else if let CommitOrChangeId :: CommitId ( id) = & self . head {
265+ self . set_real_reference ( repo, & self . head ) ?;
266+ Ok ( git2:: Oid :: from_str ( id) ?)
267+ } else {
268+ Err ( anyhow:: anyhow!(
269+ "No reference found for branch {}. CommitOrChangeId is {}" ,
270+ & self . name,
271+ & self . head
272+ ) )
273+ }
264274 }
265275
266276 /// Returns a fully qualified reference with the supplied remote e.g. `refs/remotes/origin/base-branch-improvements`
You can’t perform that action at this time.
0 commit comments