From 294846dad135e8258f037b6695fb9c0cacc77e8e Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Mon, 4 Oct 2010 20:47:01 +0200 Subject: [PATCH] tg.sh: simplify cat_file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use shell parameter expansion to strip the leading (w): and (i) Signed-off-by: Bert Wesarg Signed-off-by: Uwe Kleine-König --- tg.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tg.sh b/tg.sh index 3718702..8264a3b 100644 --- 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 } -- 2.11.4.GIT