Re: committing empty diffs
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:42:54
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