3 from subprocess import check_output
7 parser = argparse.ArgumentParser()
8 parser.add_argument("ROOT_HASH", help="root tree for the search")
9 parser.add_argument("PATH_ITEM", help="path component", nargs='*')
10 opts = parser.parse_args()
11 tree_hash = opts.ROOT_HASH
16 subtree_items = check_output(['git', 'ls-tree', '-z', tree_hash])
18 for entry in subtree_items.split('\0'):
21 info, name = entry.split('\t', 1)
22 if name == target_name:
23 _, _, target_hash = info.split(' ')
26 print >> sys.stderr, "Can't find %r in %s" % (target_name, tree_hash)
28 tree_hash = target_hash