From: Avery Pennarun Date: Fri, 1 Jan 2010 02:59:30 +0000 (-0500) Subject: 'bup join' now takes objects on the command line and handles commitids. X-Git-Tag: bup-0.01~24 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=8e0484c02148970c77f5b5c59e33bf66f87de0e7;p=bup.git 'bup join' now takes objects on the command line and handles commitids. It converts commitids directly into trees and cats the entire tree recursively. If no ids are provided on the command line, it reverts back to reading the list of objects from stdin. --- diff --git a/Makefile b/Makefile index 417ee94..8c55b26 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ runtests-cmdline: all diff -u tags1 tags2 || true wc -c testfile1 testfile2 wc -l tags1 tags2 - ./bup join out1 + ./bup join $$(cat tags1) >out1 ./bup join out2 diff -u testfile1 out1 diff -u testfile2 out2 diff --git a/cmd-join.sh b/cmd-join.sh index 0001b10..08ca3dd 100755 --- a/cmd-join.sh +++ b/cmd-join.sh @@ -5,8 +5,8 @@ get_one() { local typ="$1" local sha="$2" - if [ "$typ" = "tree" ]; then - git cat-file -p "$x" | while read nmode ntyp nsha njunk; do + if [ "$typ" = "tree" -o "$typ" = "commit" ]; then + git cat-file -p "$x:" | while read nmode ntyp nsha njunk; do get_one $ntyp $nsha done else @@ -14,7 +14,21 @@ get_one() fi } -while read x junk; do - typ="$(git cat-file -t "$x")" - get_one "$typ" "$x" -done + +get_from_stdin() +{ + while read x junk; do + [ -z "$x" ] && continue + typ="$(git cat-file -t "$x")" + get_one "$typ" "$x" + done +} + + +if [ -z "$*" ]; then + get_from_stdin +else + for d in "$@"; do + echo "$d" + done | get_from_stdin +fi