@@ -44,6 +44,12 @@ enum Command {
4444 #[ arg( long, short) ]
4545 branch : Option < String > ,
4646 } ,
47+ /// Shows the log between the given branch and its parent (git-stack tree) branch.
48+ Log {
49+ /// Specifies the branch whose log should be shown. If ommitted, the current branch will
50+ /// be used.
51+ branch : Option < String > ,
52+ } ,
4753 /// Shows the diff between the given branch and its parent (git-stack tree) branch.
4854 Diff {
4955 /// Specifies the branch whose diff should be shown. If ommitted, the current branch will
@@ -125,6 +131,7 @@ fn inner_main() -> Result<()> {
125131 Some ( Command :: Status ) | None => status ( state, & repo, & current_branch) ,
126132 Some ( Command :: Delete { branch_name } ) => state. delete_branch ( & repo, & branch_name) ,
127133 Some ( Command :: Diff { branch } ) => diff ( state, & repo, & branch. unwrap_or ( current_branch) ) ,
134+ Some ( Command :: Log { branch } ) => show_log ( state, & repo, & branch. unwrap_or ( current_branch) ) ,
128135 }
129136}
130137
@@ -145,6 +152,29 @@ fn diff(state: State, repo: &str, branch: &str) -> Result<()> {
145152 Ok ( ( ) )
146153}
147154
155+ fn show_log ( state : State , repo : & str , branch : & str ) -> Result < ( ) > {
156+ let parent_branch = state
157+ . get_parent_branch_of ( repo, branch)
158+ . ok_or_else ( || anyhow ! ( "No parent branch found for current branch: {}" , branch) ) ?;
159+ tracing:: debug!(
160+ parent_branch = & parent_branch. name,
161+ branch = branch,
162+ "Log changes"
163+ ) ;
164+ let status = git:: run_git_passthrough ( & [
165+ "log" ,
166+ "--graph" ,
167+ "--oneline" ,
168+ "-p" ,
169+ "--decorate" ,
170+ & format ! ( "{}..{}" , & parent_branch. name, branch) ,
171+ ] ) ?;
172+ if !status. success ( ) {
173+ bail ! ( "git format-patch failed" ) ;
174+ }
175+ Ok ( ( ) )
176+ }
177+
148178fn selection_marker ( ) -> & ' static str {
149179 if cfg ! ( target_os = "windows" ) {
150180 ">"
0 commit comments