[TopGit PATCH] tg.sh: simplify cat_file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use shell parameter expansion to strip the leading (w): and (i)

Signed-off-by: Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx>
---
 tg.sh |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/tg.sh b/tg.sh
index 9d08d63..d320956 100644 tg.sh
--- 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#????}"
 		;;
 	'(i):'*)
 		# ':file' means cat from index
-		arg=$(echo "$arg" | tail --bytes=+5)
-		git cat-file blob ":$arg"
+		git cat-file blob "${arg#???}"
 		;;
 	*)
 		git cat-file blob "$arg"
+		;;
 	esac
 }
 
-- 
1.7.1.1067.g5aeb7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]