]> arthur.barton.de Git - bup.git/commitdiff
'bup join' now takes objects on the command line and handles commitids.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 1 Jan 2010 02:59:30 +0000 (21:59 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 1 Jan 2010 03:04:42 +0000 (22:04 -0500)
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
cmd-join.sh

index 417ee946c54c3a9bd728c75c6cf512294cc1505c..8c55b26a11525ed8eb181958f3aad5b89a9ba416 100644 (file)
--- 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 <tags1 >out1
+       ./bup join $$(cat tags1) >out1
        ./bup join <tags2 >out2
        diff -u testfile1 out1
        diff -u testfile2 out2
index 0001b10cf39ee94aff0f433cd9a0cc72f780ced5..08ca3dd6a4e67f578e5cfbebe70c54cc34f7545e 100755 (executable)
@@ -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