@@ -93,8 +93,21 @@ impl GitRepo {
9393 branch : & str ,
9494 ) -> Result < GitBranchStatus > {
9595 let exists = self . branch_exists ( branch) ;
96+
97+ // Resolve parent branch - use origin/<parent> if local doesn't exist
9698 let parent_branch = match parent_branch {
97- Some ( parent_branch) => parent_branch. to_string ( ) ,
99+ Some ( parent_branch) => {
100+ if self . branch_exists ( parent_branch) {
101+ parent_branch. to_string ( )
102+ } else {
103+ let remote_parent = format ! ( "origin/{}" , parent_branch) ;
104+ if self . ref_exists ( & remote_parent) {
105+ remote_parent
106+ } else {
107+ parent_branch. to_string ( )
108+ }
109+ }
110+ }
98111 None => self . remote_main ( DEFAULT_REMOTE ) ?,
99112 } ;
100113
@@ -112,8 +125,16 @@ impl GitRepo {
112125 } ) ;
113126 ( sha, is_descendent, upstream_status)
114127 } else {
115- // Branch doesn't exist - use placeholder values
116- ( String :: new ( ) , false , None )
128+ // Local branch doesn't exist - try using origin/<branch> instead
129+ let remote_ref = format ! ( "origin/{}" , branch) ;
130+ if self . ref_exists ( & remote_ref) {
131+ let sha = self . sha ( & remote_ref) . unwrap_or_default ( ) ;
132+ let is_descendent = self . is_ancestor ( & parent_branch, & remote_ref) . unwrap_or ( false ) ;
133+ ( sha, is_descendent, None )
134+ } else {
135+ // Neither local nor remote exists - use placeholder values
136+ ( String :: new ( ) , false , None )
137+ }
117138 } ;
118139
119140 Ok ( GitBranchStatus {
0 commit comments