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