3 # https://sourceware.org/bugzilla/show_bug.cgi?id=26034
4 export "BUP_ARGV_0"="$0"
7 export "BUP_ARGV_${arg_i}"="$arg"
11 # Here to end of preamble replaced during install
12 bup_python="$(dirname "$0")/../../config/bin/python" || exit $?
13 exec "$bup_python" "$0"
17 from __future__ import absolute_import, print_function
18 from binascii import hexlify, unhexlify
21 sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
23 from bup import compat, git, options
24 from bup.compat import argv_bytes
25 from bup.helpers import add_error, handle_ctrl_c, log, qprogress, saved_errors
26 from bup.io import byte_stream
29 bup list-idx [--find=<prefix>] <idxfilenames...>
31 find= display only objects that start with <prefix>
33 o = options.Options(optspec)
34 opt, flags, extra = o.parse(compat.argv[1:])
38 opt.find = argv_bytes(opt.find) if opt.find else b''
41 o.fatal('you must provide at least one filename')
43 if len(opt.find) > 40:
44 o.fatal('--find parameter must be <= 40 chars long')
53 o.fatal('--find parameter is not a valid hex string')
56 out = byte_stream(sys.stdout)
57 find = opt.find.lower()
59 idxfiles = [argv_bytes(x) for x in extra]
62 ix = git.open_idx(name)
63 except git.GitError as e:
64 add_error('%r: %s' % (name, e))
66 if len(opt.find) == 40:
68 out.write(b'%s %s\n' % (name, find))
70 # slow, exhaustive search
73 if i.startswith(find):
74 out.write(b'%s %s\n' % (name, i))
75 qprogress('Searching: %d\r' % count)
79 log('WARNING: %d errors encountered while saving.\n' % len(saved_errors))