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

Re: [PATCH] git-commit: add --verbatim to allow unstripped commit messages

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Dec 20, 2007, 23:55 UTC
Message-ID
<alpine.LFD.0.9999.0712201545450.21557@woody.linux-foundation.org>
In-Reply-To
<20071220233324.GB3052@steel.home>
On Fri, 21 Dec 2007, Alex Riesen wrote:
Show 7 quoted lines
> 
> Yes, I afraid I need both. I use "git commit -t" almost (submission in
> perforce takes careful planning) every day. I also would like to keep
> the empty leading and trailing lines (perforce default GUI P4Win does
> not show them, but our scripts which check the descriptions will test
> the description text according to template which does have trailing
> empty lines).

Hmm. I think your updated patch was pretty good, although I still think it could be improved a bit. In particular, thinking more about it, I think we have more than an "on/off" switch - we really have three cases:

 a) strip whitespace _and_ comments
 b) strip unnecessary whitespace only
 c) leave things _totally_ alone
and on top of that we also have the issue of an editor.

So my patch basically said that in the absense of an editor, we'll still clean up whitespace, but not comments (ie "no_edit" implies doing (b) rather than (b)), while your patch basically results in (c) regardless of whether we run an editor or not.

But that still leaves one case: do we ever want to do (b) even *if* we use an editor? There's another possible choice: our old behaviour of (a) in the presense of an editor is now gone.

Now, that last choice (ie "case (a) without an editor") is not only unlikely to be anything people want to do anyway, it's also easy enough to do by just using "git stripspace -s" on whatever non-editor thing you feed to "git commit", so I don't think we need to worry about that one.

But the "maybe you want to run an editor, and you _do_ want case (b)" sounds like a case that is not at all unlikely. I could easily see the case where you want to have a template that uses '#', and *despite* that you want to (a) allow the user to edit things _and_ (b) clean up whitespace too.

So I'd almost suggest you make the "--verbatim" flag a three-way switch, to allow "totally verbatim" (leave everything in place) and a "don't touch comments" (just fix up whitespace) mode.

Hmm? Does that make sense to you?
			Linus
Previous: Alex RiesenNext: Björn Steinbrink
Message 10 of 23 in “git-commit: add --verbatim to allow unstripped commit messages”
  1. git-commit: add --verbatim to allow unstripped commit messagesAlex Riesen, Dec 20, 2007
  2. Linus TorvaldsDec 20, 2007
  3. Alex RiesenDec 20, 2007
  4. git-commit: add --verbatim to allow unstripped commit messagesAlex Riesen, Dec 20, 2007
  5. Only filter "#" comments from commits if the editor is usedAlex Riesen, Dec 20, 2007
  6. Junio C HamanoDec 20, 2007
  7. Alex RiesenDec 20, 2007
  8. Junio C HamanoDec 20, 2007
  9. Fix thinko in checking for commit message emptinessAlex Riesen, Dec 20, 2007
  10. Linus TorvaldsDec 20, 2007
  11. Björn SteinbrinkDec 21, 2007
  12. Linus TorvaldsDec 21, 2007
  13. Junio C HamanoDec 20, 2007
  14. Linus TorvaldsDec 21, 2007
  15. Allow selection of different cleanup modes for commit messagesAlex Riesen, Dec 21, 2007
  16. Junio C HamanoDec 21, 2007
  17. Allow selection of different cleanup modes for commit messagesAlex Riesen, Dec 21, 2007
  18. Junio C HamanoDec 22, 2007
  19. Allow selection of different cleanup modes for commit messagesAlex Riesen, Dec 22, 2007
  20. Linus TorvaldsDec 22, 2007
  21. Junio C HamanoDec 22, 2007
  22. Junio C HamanoDec 23, 2007
  23. Junio C HamanoDec 23, 2007

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.