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]

 



Am 31.08.23 um 12:58 schrieb Gareth Hayes:
> 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`

XY-problem alert!?

> 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?

Recall that the -p in cat-file means "pretty" (-print). The data that
makes up a tree object is far from pretty, hence, you can't feed it into
git hash-object directly.

You can either turn the pretty-printed input into a tree object

   git cat-file -p $treeoid | git mktree

or hash the raw data

   git cat-file tree $treeoid | git hash-object -t tree --stdin


-- Hannes




[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