]> arthur.barton.de Git - bup.git/blob - cmd/join-cmd.py
Git: Ignore two more generated files
[bup.git] / cmd / join-cmd.py
1 #!/bin/sh
2 """": # -*-python-*-
3 bup_python="$(dirname "$0")/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
5 """
6 # end of bup preamble
7
8 import sys
9
10 from bup import git, options, client
11 from bup.helpers import linereader, log
12
13
14 optspec = """
15 bup join [-r host:path] [refs or hashes...]
16 --
17 r,remote=  remote repository path
18 o=         output filename
19 """
20 o = options.Options(optspec)
21 (opt, flags, extra) = o.parse(sys.argv[1:])
22
23 git.check_repo_or_die()
24
25 if not extra:
26     extra = linereader(sys.stdin)
27
28 ret = 0
29
30 if opt.remote:
31     cli = client.Client(opt.remote)
32     cat = cli.cat
33 else:
34     cp = git.CatPipe()
35     cat = cp.join
36
37 if opt.o:
38     outfile = open(opt.o, 'wb')
39 else:
40     outfile = sys.stdout
41
42 for id in extra:
43     try:
44         for blob in cat(id):
45             outfile.write(blob)
46     except KeyError as e:
47         outfile.flush()
48         log('error: %s\n' % e)
49         ret = 1
50
51 sys.exit(ret)