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

Re: committing empty diffs

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 12, 2007, 20:10 UTC
Message-ID
<Pine.LNX.4.64.0702121202480.8424@woody.linux-foundation.org>
In-Reply-To
<68948ca0702121149p4d87ae07jd3aa532a0df79156@mail.gmail.com>
On Mon, 12 Feb 2007, Don Zickus wrote:
> 
> Considering git-commit doesn't allow this (probably for good reason),
> is it technically safe to do the following sequence of events?

Yes. There's nothing *technically* wrong with an empty commit. The reason "git commit" doesn't do it is that it's just almost always a mistake.

> tree=$(git-write-tree)  #basically the same tree HEAD points to
> commit=$(echo $IDEAS | git-commit-tree $tree -p HEAD)
> git-update-ref HEAD $commit HEAD

If you know ahead-of-time that the tree is HEAD, there's no reason to do the "git-write-tree". You can just use "HEAD^{tree}" instead (and in fact, I think git-commit-tree will happily just take HEAD directly).

And please give a log messages for "git-update-ref"

Please do make sure to do some of the other sanity checks that "git commit" does, though. It is a good idea to at least verify that the commit message isn't empty etc.

		Linus
Previous: Don Zickus
Message 5 of 5 in “committing empty diffs”
  1. Don ZickusFeb 12, 2007
  2. Shawn O. PearceFeb 12, 2007
  3. Shawn O. PearceFeb 12, 2007
  4. Don ZickusFeb 12, 2007
  5. Linus TorvaldsFeb 12, 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.