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

Re: Can't diff against the 00000000 revision

From
Jeff King <peff@peff.net>
Date
Jan 12, 2016, 15:37 UTC
Message-ID
<20160112153757.GB8041@sigill.intra.peff.net>
In-Reply-To
<20160112153239.GA8041@sigill.intra.peff.net>
On Tue, Jan 12, 2016 at 10:32:39AM -0500, Jeff King wrote:
Show 10 quoted lines
> > I currently work around the problem by adding a dummy empty branch, but
> > being able to use the revision 00000000 as a known reference to an empty
> > tree would come in really handy, and since it's already used at various
> > places in Git (post-receive hook and "git show" output, at least), it
> > would seem like a natural extension.
> 
> The empty tree also has a name:
> 
>   $ git hash-object -t tree /dev/null
>   4b825dc642cb6eb9a060e54bf8d69288fbee4904

By the way, the empty tree and empty blob objects are baked-in to git, so you can always rely on diffing against them. IOW, it is fine to write:

  while read old new ref; do
	if test "$old" = "0000000000000000000000000000000000000000"; then
		old=4b825dc642cb6eb9a060e54bf8d69288fbee4904
	fi
	git diff-tree $old $new | whatever_checks_you_want_to_do
  done
in your post-receive hook.
-Peff
Previous: Jeff KingNext: Stefan Monnier
Message 3 of 8 in “Can't diff against the 00000000 revision”
  1. Stefan MonnierJan 12, 2016
  2. Jeff KingJan 12, 2016
  3. Jeff KingJan 12, 2016
  4. Stefan MonnierJan 12, 2016
  5. Jeff KingJan 12, 2016
  6. Junio C HamanoJan 12, 2016
  7. Andreas SchwabJan 12, 2016
  8. Jeff KingJan 12, 2016

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.