Better cat-file tree format

This commit is contained in:
Nathan McRae 2024-07-13 21:03:29 -07:00
parent 3d08e348db
commit cc32d87d4d
2 changed files with 5 additions and 2 deletions

View File

@ -286,7 +286,11 @@ def cmd_cat_file(args):
def cat_file(repo, obj, fmt=None):
obj = object_read(repo, object_find(repo, obj, fmt=fmt))
sys.stdout.buffer.write(obj.serialize())
if fmt == b'tree':
for item in obj.items:
print(f"{item.mode.decode('ascii')} {item.path} {item.sha}")
else:
sys.stdout.buffer.write(obj.serialize())
def object_find(repo, name, fmt=None, follow=True):
sha = object_resolve(repo, name)

1
test

@ -1 +0,0 @@
Subproject commit d53851a324df2b0b1090b51b5f8a7c19dacb3fcc