[PATCH] Automatically line wrap long commit messages.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When using -m on the command line with git-commit it is not uncommon
for a long commit message to be entered without line terminators.
This creates commit objects whose messages are not readable in
'git log' as the line runs off the screen.

So instead reformat log messages if they are supplied on the
command line.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 This one might cause some problems for people.  It requires
 'fmt' in order to use log messages on the command line as well as
 some users may not like having their log messages line wrapped.
 I'm open to suggestions for how to deal with this but personally
 this is one feature which I put into pg's commit tool that I miss
 dearly when working with core GIT.

 git-commit.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/git-commit.sh b/git-commit.sh
index a092b72..e7aa4b1 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -547,7 +547,12 @@ fi
 
 if test "$log_message" != ''
 then
-	echo "$log_message"
+	# The message came from the command line.  It might contain very
+	# long lines so reformat it with a target of 60. Note that we
+	# don't reformat messages created in an editor by the user as
+	# we should assume they carefully formatted it in some way.
+	#
+	echo "$log_message" | fmt -w 60
 elif test "$logfile" != ""
 then
 	if test "$logfile" = -
-- 
1.3.3.g45d8

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]