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

[PATCH] git-commit: filter out log message lines only when editor was run.

From
Yann Dirson <ydirson@altern.org>
Date
Jun 23, 2006, 22:04 UTC
Message-ID
<20060623220405.1915.28636.stgit@gandelf.nowhere.earth>

The current behaviour strips out lines starting with a # even when fed through stdin or -m. This is particularly bad when importing history from another SCM (tailor 0.9.23 uses git-commit). In the best cases all lines are stripped and the commit fails with a confusing "empty log message" error, but in many cases the commit is done, with loss of information.

Note that it is quite peculiar to just have "#" handled as a leading comment char here. One commonly meet CVS: or CG: or STG: as prefixes, and using GIT: would be more robust as well as consistent with other commit tools. However, that would break any tool relying on the # (if any).

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 git-commit.sh |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index 6dd04fd..aa3b1ea 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -691,13 +691,18 @@ t)
 	fi
 esac
 
-sed -e '
-    /^diff --git a\/.*/{
-	s///
-	q
-    }
-    /^#/d
-' "$GIT_DIR"/COMMIT_EDITMSG |
+if test -z "$no_edit"
+then
+    sed -e '
+        /^diff --git a\/.*/{
+	    s///
+	    q
+	}
+	/^#/d
+    ' "$GIT_DIR"/COMMIT_EDITMSG
+else
+    cat "$GIT_DIR"/COMMIT_EDITMSG
+fi |
 git-stripspace >"$GIT_DIR"/COMMIT_MSG
 
 if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
Next: Junio C Hamano
Message 1 of 2 in “git-commit: filter out log message lines only when editor was run.”
  1. git-commit: filter out log message lines only when editor was run.Yann Dirson, Jun 23, 2006
  2. Junio C HamanoJun 24, 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.