Linus Torvalds wrote:
On Tue, 9 Aug 2005, John Ellson wrote:
I hacked this:
So you could do something like ...
Thanks Linus, also Rene and Johannes.
I applied a bit of polish and testing and now I'm ready to offer
my first contribution to cogito.
cg-cat [-r rev] FILE
I hope that this is useful to others.
Signed-off-by: John Ellson <[EMAIL PROTECTED]>
diff --git a/Makefile b/Makefile
@@ -14,11 +14,11 @@ INSTALL?=install
SCRIPT= commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
cg-branch-add cg-branch-ls cg-reset cg-clone cg-commit cg-diff \
cg-export cg-help cg-init cg-log cg-merge cg-mkpatch cg-patch \
cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
- cg cg-admin-ls cg-push cg-branch-chg
+ cg cg-admin-ls cg-push cg-branch-chg cg-cat
LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xnormid
diff --git a/cg-cat b/cg-cat
new file mode 100755
@@ -0,0 +1,42 @@
+# Cat a file(s) by filename from a GIT repository.
+# Initiated from a request from: [EMAIL PROTECTED]
+# for an equivalent to "cvs co -p <filename>"
+# Question posted with really bad initial solution: [EMAIL PROTECTED]
+# Suggestions offered by: [EMAIL PROTECTED]
+# [EMAIL PROTECTED]
+# This solution based on posting from: [EMAIL PROTECTED]
+# Polish and test by: [EMAIL PROTECTED]
+USAGE="cg-cat [-r rev] FILE"
+while optparse; do
+ if optparse -r; then
+[ "$ARGS" ] || usage
+git-ls-tree $(git-rev-parse --default $default "[EMAIL PROTECTED]") |
+ while read mode type sha name
+ case "$type" in
+ git-cat-file blob "$sha"
+ git-ls-tree "$sha"
+ exit 1