git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[TopGit PATCH] tg.sh: simplify cat_file

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 4, 2010, 18:43 UTC
Message-ID
<85c8c215f362c4b57e7646d536ef1ca77ade1591.1286217707.git.bert.wesarg@googlemail.com>
Use shell parameter expansion to strip the leading (w): and (i)
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 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
Next: Bert Wesarg
Message 1 of 2 in “tg.sh: simplify cat_file”
  1. tg.sh: simplify cat_fileBert Wesarg, Oct 4, 2010
  2. tg.sh: simplify cat_fileBert Wesarg, Oct 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.