Re: Can't diff against the 00000000 revision

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 12, 2016 at 10:32:39AM -0500, Jeff King wrote:

> > 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]