From: Bert Wesarg Date: Mon, 4 Oct 2010 18:47:01 +0000 (+0200) Subject: tg.sh: simplify cat_file X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=294846dad135e8258f037b6695fb9c0cacc77e8e;p=topgit.git tg.sh: simplify cat_file Use shell parameter expansion to strip the leading (w): and (i) Signed-off-by: Bert Wesarg Signed-off-by: Uwe Kleine-König --- 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 }