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")/bup-python" || exit $?
13 exec "$bup_python" "$0"
17 from __future__ import absolute_import, print_function
18 from binascii import hexlify, unhexlify
21 from bup import compat, git, options
22 from bup.compat import argv_bytes
23 from bup.helpers import add_error, handle_ctrl_c, log, qprogress, saved_errors
24 from bup.io import byte_stream
27 bup list-idx [--find=<prefix>] <idxfilenames...>
29 find= display only objects that start with <prefix>
31 o = options.Options(optspec)
32 opt, flags, extra = o.parse(compat.argv[1:])
36 opt.find = argv_bytes(opt.find) if opt.find else b''
39 o.fatal('you must provide at least one filename')
41 if len(opt.find) > 40:
42 o.fatal('--find parameter must be <= 40 chars long')
51 o.fatal('--find parameter is not a valid hex string')
54 out = byte_stream(sys.stdout)
55 find = opt.find.lower()
57 idxfiles = [argv_bytes(x) for x in extra]
60 ix = git.open_idx(name)
61 except git.GitError as e:
62 add_error('%r: %s' % (name, e))
64 if len(opt.find) == 40:
66 out.write(b'%s %s\n' % (name, find))
68 # slow, exhaustive search
71 if i.startswith(find):
72 out.write(b'%s %s\n' % (name, i))
73 qprogress('Searching: %d\r' % count)
77 log('WARNING: %d errors encountered while saving.\n' % len(saved_errors))