]> arthur.barton.de Git - bup.git/blob - cmd-join.sh
We can now update refs when we do a backup.
[bup.git] / cmd-join.sh
1 #!/bin/sh
2 set -e
3
4 if [ -z "$BUP_DIR" ]; then
5     BUP_DIR="$HOME/.bup"
6 fi
7
8 export GIT_DIR="$BUP_DIR"
9
10 get_one()
11 {
12     local typ="$1"
13     local sha="$2"
14     if [ "$typ" = "tree" -o "$typ" = "commit" ]; then
15         git cat-file -p "$x:" | while read nmode ntyp nsha njunk; do
16             get_one $ntyp $nsha
17         done
18     else
19         git cat-file blob "$sha"
20     fi
21 }
22
23
24 get_from_stdin()
25 {
26     while read x junk; do
27         [ -z "$x" ] && continue
28         typ="$(git cat-file -t "$x")"
29         get_one "$typ" "$x"
30     done
31 }
32
33
34 if [ -z "$*" ]; then
35     get_from_stdin
36 else
37     for d in "$@"; do
38         echo "$d"
39     done | get_from_stdin
40 fi