1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-25 01:06:39 +00:00

Allow 'cat' for tree blobs

This commit is contained in:
Alexander Neumann 2016-08-28 21:23:46 +02:00
parent 6c6b0e2395
commit 3af8f53097

View file

@ -166,20 +166,24 @@ func (cmd CmdCat) Execute(args []string) error {
return err
case "blob":
list, err := repo.Index().Lookup(id, pack.Data)
if err != nil {
return err
}
blob := list[0]
for _, t := range []pack.BlobType{pack.Data, pack.Tree} {
list, err := repo.Index().Lookup(id, t)
if err != nil {
continue
}
blob := list[0]
buf := make([]byte, blob.Length)
data, err := repo.LoadBlob(id, pack.Data, buf)
if err != nil {
buf := make([]byte, blob.Length)
data, err := repo.LoadBlob(id, t, buf)
if err != nil {
return err
}
_, err = os.Stdout.Write(data)
return err
}
_, err = os.Stdout.Write(data)
return err
return errors.New("blob not found")
case "tree":
debug.Log("cat", "cat tree %v", id.Str())