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

Re: [PATCH] Add option to git-commit to allow empty log messages

From
Jeff King <peff@peff.net>
Date
Apr 6, 2010, 05:55 UTC
Message-ID
<20100406055530.GE3901@coredump.intra.peff.net>
In-Reply-To
<20100405175822.GA32083@progeny.tock>
On Mon, Apr 05, 2010 at 12:58:22PM -0500, Jonathan Nieder wrote:
Show 7 quoted lines
> > There's probably a lot of code out there doing `git commit -m"Yet
> > another revision"' from some cron job.
> 
> FWIW, I have no strong opinion about whether to add this --allow-empty-message
> option.  Maybe it would make something more convenient for someone,
> though that has to be weighed against it making it harder for everyone
> else to read the manual.

I meant to mention this in my other response: I would prefer if such an option doesn't clutter up the usage message. --allow-empty is already there, and probably doesn't need to be. "git commit -h 2>&1 | wc -l" shows a whopping 39 lines, which IMHO is too many for a short usage summary. I mean, "--no-post-rewrite", is that really one of the top-used options?

Show 7 quoted lines
> Hint:
> 
> 	parent=HEAD && : or whatever &&
> 	tree=$(git write-tree) &&
> 	printf "%s\n" message |
> 	commit=$(git commit-tree "$tree" -p "$parent") &&
> 	git update-ref refs/heads/somebranch "$commit"
In addition to the bug you mention later, you also probably want to do:
  parent=`git rev-parse --verify HEAD`
  [...]
  git update-ref \
    -m 'automated commit by tool X' \
    refs/heads/somebranch $commit $parent

which will give your reflog entry a more useful message, and will protect against simultaneous updates losing history (update-ref will make sure, while locked, that somebranch contains the $parent sha1 you wrote as part of the commit object).

And of course it still doesn't handle parentless root commits.

So doing it right really is a bit more work than just calling "git commit".

-Peff
Previous: Jonathan NiederNext: Ævar Arnfjörð Bjarmason
Message 16 of 35 in “Does Git really need a commit message to go with a commit?”
  1. Ævar Arnfjörð BjarmasonApr 3, 2010
  2. Avery PennarunApr 4, 2010
  3. Add option to git-commit to allow empty log messagesÆvar Arnfjörð Bjarmason, Apr 4, 2010
  4. David AguilarApr 4, 2010
  5. Ævar Arnfjörð BjarmasonApr 4, 2010
  6. Junio C HamanoApr 5, 2010
  7. Sverre RabbelierApr 5, 2010
  8. Junio C HamanoApr 5, 2010
  9. Sverre RabbelierApr 5, 2010
  10. Miles BaderApr 5, 2010
  11. Junio C HamanoApr 5, 2010
  12. Jeff KingApr 5, 2010
  13. Ævar Arnfjörð BjarmasonApr 5, 2010
  14. Jonathan NiederApr 5, 2010
  15. Jonathan NiederApr 5, 2010
  16. Jeff KingApr 6, 2010
  17. Add option to git-commit to allow empty log messagesÆvar Arnfjörð Bjarmason, Apr 6, 2010
  18. Junio C HamanoApr 7, 2010
  19. Ævar Arnfjörð BjarmasonApr 7, 2010
  20. Ævar Arnfjörð BjarmasonApr 6, 2010
  21. Remove --allow-empty from the git-commit synopsisÆvar Arnfjörð Bjarmason, Apr 7, 2010
  22. Sverre RabbelierApr 7, 2010
  23. Remove --allow-empty from the git-commit synopsisÆvar Arnfjörð Bjarmason, Apr 7, 2010
  24. Sverre RabbelierApr 7, 2010
  25. Ævar Arnfjörð BjarmasonApr 7, 2010
  26. Tay Ray ChuanApr 7, 2010
  27. Remove --allow-empty from the git-commit synopsisÆvar Arnfjörð Bjarmason, Apr 7, 2010
  28. Johannes SixtApr 7, 2010
  29. Junio C HamanoApr 7, 2010
  30. Remove --allow-empty from the git-commit synopsisÆvar Arnfjörð Bjarmason, Apr 7, 2010
  31. Stephen BoydApr 7, 2010
  32. Junio C HamanoApr 7, 2010
  33. Jeff KingApr 8, 2010
  34. Jeff KingApr 6, 2010
  35. Santi BéjarApr 4, 2010

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.