Permalink
Browse files

tg.sh: simplify cat_file

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>
  • Loading branch information...
1 parent 7aeb4b9 commit 294846dad135e8258f037b6695fb9c0cacc77e8e @bertwesarg bertwesarg committed with Uwe Kleine-König Oct 4, 2010
Showing with 3 additions and 5 deletions.
  1. +3 −5 tg.sh
View
@@ -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
}

0 comments on commit 294846d

Please sign in to comment.