git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Automatically line wrap long commit messages.

From
Shawn Pearce <spearce@spearce.org>
Date
May 29, 2006, 08:57 UTC
Message-ID
<20060529085738.GB29500@spearce.org>

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@spearce.org>
---
 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
Next: Jan-Benedict Glaw
Message 1 of 10 in “Automatically line wrap long commit messages.”
  1. Automatically line wrap long commit messages.Shawn Pearce, May 29, 2006
  2. Jan-Benedict GlawMay 29, 2006
  3. Shawn PearceMay 29, 2006
  4. Junio C HamanoMay 29, 2006
  5. Shawn PearceMay 29, 2006
  6. Junio C HamanoMay 30, 2006
  7. Shawn PearceMay 31, 2006
  8. Junio C HamanoMay 31, 2006
  9. Shawn PearceJun 1, 2006
  10. Junio C HamanoJun 1, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.