shithub: git9

Download patch

ref: df100f742b2efd4dd84af63f811c555696da52d9
parent: 542d69a45a4d26ba99280ede5e77d5ecff97db1f
author: Michael Forney <mforney@mforney.org>
date: Sun Jan 31 21:03:09 EST 2021

git/commit: add -e flag to edit commit message

This is useful with -r to amend a commit message in an editor. It can
also be useful with -m when you realize you want to elaborate on a
commit message, but have already typed the subject line as a flag.

--- a/commit
+++ b/commit
@@ -62,6 +62,9 @@
 			echo '#'
 			echo '# Commit message:'
 		}
+		edit=1
+	}
+	if(! ~ $#edit 0){
 		giteditor=`{git/conf core.editor}
 		if(~ $#editor 0)
 			editor=$giteditor
@@ -118,7 +121,7 @@
 
 gitup
 
-flagfmt='m:msg message, r:revise'; args='file ...'
+flagfmt='m:msg message, r:revise, e:edit'; args='file ...'
 eval `''{aux/getflags $*} || exec aux/usage
 if(~ $#* 0)
 	exec aux/usage
--- a/git.1.man
+++ b/git.1.man
@@ -36,7 +36,7 @@
 .PP
 .B git/commit
 [
-.B -r
+.B -re
 ]
 [
 .B -m msg
@@ -327,14 +327,20 @@
 By default, an editor is opened to prepare the commit message.
 The
 .I -m
-supplies the commit message directly.
+flag supplies the commit message directly.
 The
 .I -r
 flag revises the contents of the previous commit, reusing the message.
-To a commit message,
+The
+.I -e
+flag opens an editor to finalize the commit message, regardless of
+whether or not it was specified explicitly or reused.
+To amend a commit message,
 .I -r
 can be used in conjuction with
-.IR -m .
+.I -m
+or
+.IR -e .
 
 .PP
 .B Git/branch