@@ -184,6 +184,13 @@ fn rev_arg<'a, 'b>() -> Arg<'a, 'b> {
184184 . default_value ( "@" )
185185}
186186
187+ fn message_arg < ' a , ' b > ( ) -> Arg < ' a , ' b > {
188+ Arg :: with_name ( "message" )
189+ . long ( "message" )
190+ . short ( "m" )
191+ . takes_value ( true )
192+ }
193+
187194fn op_arg < ' a , ' b > ( ) -> Arg < ' a , ' b > {
188195 Arg :: with_name ( "operation" )
189196 . long ( "operation" )
@@ -335,16 +342,12 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
335342 let describe_command = SubCommand :: with_name ( "describe" )
336343 . about ( "edit the commit description" )
337344 . arg ( rev_arg ( ) )
338- . arg (
339- Arg :: with_name ( "message" )
340- . long ( "message" )
341- . short ( "m" )
342- . takes_value ( true ) ,
343- )
345+ . arg ( message_arg ( ) )
344346 . arg ( Arg :: with_name ( "stdin" ) . long ( "stdin" ) ) ;
345347 let close_command = SubCommand :: with_name ( "close" )
346348 . about ( "mark a commit closed, making new work go into a new commit" )
347- . arg ( rev_arg ( ) ) ;
349+ . arg ( rev_arg ( ) )
350+ . arg ( message_arg ( ) ) ;
348351 let open_command = SubCommand :: with_name ( "open" )
349352 . about ( "mark a commit open, making new work be added to it" )
350353 . arg ( rev_arg ( ) ) ;
@@ -394,7 +397,8 @@ fn get_app<'a, 'b>() -> App<'a, 'b> {
394397 . index ( 1 )
395398 . required ( true )
396399 . multiple ( true ) ,
397- ) ;
400+ )
401+ . arg ( message_arg ( ) ) ;
398402 let rebase_command = SubCommand :: with_name ( "rebase" )
399403 . about ( "move a commit to a different parent" )
400404 . arg ( rev_arg ( ) )
@@ -1246,10 +1250,15 @@ fn cmd_close(
12461250 let commit = resolve_revision_arg ( ui, mut_repo, sub_matches) ?;
12471251 let mut commit_builder =
12481252 CommitBuilder :: for_rewrite_from ( ui. settings ( ) , repo. store ( ) , & commit) . set_open ( false ) ;
1249- if commit. description ( ) . is_empty ( ) {
1250- let description = edit_description ( & repo, commit. description ( ) ) ;
1251- commit_builder = commit_builder. set_description ( description) ;
1253+ let description;
1254+ if sub_matches. is_present ( "message" ) {
1255+ description = sub_matches. value_of ( "message" ) . unwrap ( ) . to_string ( ) ;
1256+ } else if commit. description ( ) . is_empty ( ) {
1257+ description = edit_description ( & repo, "" ) ;
1258+ } else {
1259+ description = commit. description ( ) . to_string ( ) ;
12521260 }
1261+ commit_builder = commit_builder. set_description ( description) ;
12531262 let mut tx = repo. start_transaction ( & format ! ( "close commit {}" , commit. id( ) . hex( ) ) ) ;
12541263 commit_builder. write_to_transaction ( & mut tx) ;
12551264 update_checkout_after_rewrite ( ui, & mut tx) ;
@@ -1562,7 +1571,12 @@ fn cmd_merge(
15621571 parent_ids. push ( commit. id ( ) . clone ( ) ) ;
15631572 commits. push ( commit) ;
15641573 }
1565- let description = edit_description ( & repo, "" ) ;
1574+ let description;
1575+ if sub_matches. is_present ( "message" ) {
1576+ description = sub_matches. value_of ( "message" ) . unwrap ( ) . to_string ( ) ;
1577+ } else {
1578+ description = edit_description ( & repo, "" ) ;
1579+ }
15661580 let merged_tree = merge_commit_trees ( repo. store ( ) , & commits) ;
15671581 let mut tx = repo. start_transaction ( "merge commits" ) ;
15681582 CommitBuilder :: for_new_commit ( ui. settings ( ) , repo. store ( ) , merged_tree. id ( ) . clone ( ) )
0 commit comments