@@ -75,7 +75,9 @@ fn inner_main() -> Result<()> {
7575 let current_branch = run_git ( & [ "rev-parse" , "--abbrev-ref" , "HEAD" ] ) ?
7676 . output ( )
7777 . ok_or ( anyhow ! ( "No current branch?" ) ) ?;
78- let current_upstream = run_git ( & [ "rev-parse" , "--abbrev-ref" , "@{upstream}" ] ) ?. output ( ) ;
78+ let current_upstream = run_git ( & [ "rev-parse" , "--abbrev-ref" , "@{upstream}" ] )
79+ . ok ( )
80+ . and_then ( |out| out. output ( ) ) ;
7981 tracing:: debug!( run_version, current_branch, current_upstream) ;
8082
8183 match args. command {
@@ -95,7 +97,19 @@ fn selection_marker() -> &'static str {
9597 }
9698}
9799
98- fn recur_tree ( branch : & Branch , depth : usize , orig_branch : & str ) {
100+ fn recur_tree (
101+ branch : & Branch ,
102+ depth : usize ,
103+ orig_branch : & str ,
104+ parent_branch : Option < & str > ,
105+ ) -> Result < ( ) > {
106+ let branch_status: GitBranchStatus = git_branch_status ( parent_branch, & branch. name )
107+ . with_context ( || {
108+ format ! (
109+ "attempting to fetch the branch status of {}" ,
110+ branch. name. red( )
111+ )
112+ } ) ?;
99113 let is_current_branch = if branch. name == orig_branch {
100114 print ! ( "{} " , selection_marker( ) . purple( ) ) ;
101115 true
@@ -109,17 +123,38 @@ fn recur_tree(branch: &Branch, depth: usize, orig_branch: &str) {
109123 }
110124
111125 println ! (
112- "{}" ,
126+ "{} {} " ,
113127 if is_current_branch {
114128 branch. name. green( )
115129 } else {
116130 branch. name. truecolor( 178 , 178 , 178 )
131+ } ,
132+ {
133+ let details: String = if branch_status. exists {
134+ if branch_status. is_descendent {
135+ format!(
136+ "{} with {}" ,
137+ "is up to date" . truecolor( 90 , 120 , 87 ) ,
138+ branch_status. parent_branch. yellow( )
139+ )
140+ } else {
141+ format!(
142+ "{} {}" ,
143+ "is behind" . red( ) ,
144+ branch_status. parent_branch. yellow( )
145+ )
146+ }
147+ } else {
148+ "does not exist" . red( ) . to_string( )
149+ } ;
150+ details
117151 }
118152 ) ;
119153
120154 for child in & branch. branches {
121- recur_tree ( child, depth + 1 , orig_branch) ;
155+ recur_tree ( child, depth + 1 , orig_branch, Some ( branch . name . as_ref ( ) ) ) ? ;
122156 }
157+ Ok ( ( ) )
123158}
124159
125160fn status ( state : State , repo : & str , orig_branch : & str ) -> Result < ( ) > {
@@ -132,7 +167,7 @@ fn status(state: State, repo: &str, orig_branch: &str) -> Result<()> {
132167 ) ;
133168 return Ok ( ( ) ) ;
134169 } ;
135- recur_tree ( tree, 0 , orig_branch) ;
170+ recur_tree ( tree, 0 , orig_branch, None ) ? ;
136171 /*
137172 let stacks = state.get_stacks(repo);
138173 if stacks.is_empty() {
0 commit comments