chiark / gitweb /
tg.sh: simplify cat_file
authorBert Wesarg <bert.wesarg@googlemail.com>
Mon, 4 Oct 2010 18:47:01 +0000 (20:47 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 5 Oct 2010 06:47:56 +0000 (08:47 +0200)
Use shell parameter expansion to strip the leading (w): and (i)

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg.sh

diff --git a/tg.sh b/tg.sh
index 3718702e5cd20eb0aefcfbb36a77801411c88978..8264a3b074f1d6bbded09e8110f1c07be475ffdd 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -25,17 +25,15 @@ cat_file()
        arg="$1"
        case "$arg" in
        '(w):'*)
-               arg=$(echo "$arg" | tail --bytes=+5)
-               cat "$arg"
-               return
+               cat "${arg#(w):}"
                ;;
        '(i):'*)
                # ':file' means cat from index
-               arg=$(echo "$arg" | tail --bytes=+5)
-               git cat-file blob ":$arg"
+               git cat-file blob "${arg#(i)}"
                ;;
        *)
                git cat-file blob "$arg"
+               ;;
        esac
 }