Re: Problem: `fatal: too-short tree object` when executing hash-object on tree

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

 



"Gareth Hayes" <gareth.hayes@xxxxxxxxxxxxxx> writes:

> Problem: I'm trying to reproduce the identifier of a tree object using `git cat-file -p <tree object identifier> | git hash-object -t tree --stdin`
>
> This results in an error:
> `fatal: too-short tree object`
>
> To replicate: 
> `git cat-file -p HEAD`
> `git cat-file -p <tree object identifier from output of above> | git hash-object -t tree --stdin`
>
> This works for other object types but not trees. What am I doing wrong?

It would work *ONLY* for blob, and not commit or tag object types,
no?

The "-p" option is to present the object in a human-friendly format,
as opposed to giving the raw stream of bytes that is suitable for
machine consumption and required by hash-object.  It so happens that
for "blob", the raw stream of bytes is just as human-friendly as the
tool can make, without having a deep knowledge of the content type
(e.g. it may be possible to make "cat-file -p <blob>" to somehow
apply an appropriate textconv filter if the path to <blob> is known
as a future enhancement, but such a code does not exist yet, and
when it happens, even "cat-file -p <blob> | hash-object --stdin"
would not round-trip).

So, that is what you are doing wrong, I think.



[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]

  Powered by Linux