From 8e0484c02148970c77f5b5c59e33bf66f87de0e7 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Thu, 31 Dec 2009 21:59:30 -0500 Subject: [PATCH] '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. --- Makefile | 2 +- cmd-join.sh | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) 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 -- 2.39.5