3 bup_exec="$(dirname "$0")/bup-exec" || exit $?
4 exec "$bup_exec" "$0" ${1+"$@"}
7 from __future__ import absolute_import, print_function
10 from bup.compat import argv_bytes, get_argvb
11 from bup.helpers import handle_ctrl_c, readpipe
12 from bup.io import byte_stream
13 from bup import options
17 subtree-hash ROOT_HASH [PATH_ITEM...]
23 o = options.Options(optspec)
24 opt, flags, extra = o.parse_bytes(get_argvb()[1:])
27 o.fatal('must specify a root hash')
29 tree_hash = argv_bytes(extra[0])
30 path = [argv_bytes(x) for x in extra[1:]]
34 subtree_items = readpipe([b'git', b'ls-tree', b'-z', tree_hash])
36 for entry in subtree_items.split(b'\0'):
39 info, name = entry.split(b'\t', 1)
40 if name == target_name:
41 _, _, target_hash = info.split(b' ')
44 print("Can't find %r in %s" % (target_name, tree_hash.decode('ascii')),
47 tree_hash = target_hash
54 out = byte_stream(sys.stdout)
55 out.write(tree_hash + b'\n')