All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Ellson <ellson@research.att.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] cg-cat   [was: Re: Newbie question:  equiv of:  cvs co -p <filename>  ? ]
Date: Wed, 10 Aug 2005 10:38:08 -0400	[thread overview]
Message-ID: <42FA1150.7090506@research.att.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0508091725120.3258@g5.osdl.org>

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Linus Torvalds wrote:
> 
> On Tue, 9 Aug 2005, John Ellson wrote:
> 
>>I hacked this:

> No. ...

> So you could do something like ...

> (totally untested)
> 
> 		Linus


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 <ellson@research.att.com>

---

[-- Attachment #2: patch0.patch --]
[-- Type: text/x-patch, Size: 1549 bytes --]

diff --git a/Makefile b/Makefile
--- 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
 
 GEN_SCRIPT= cg-version
 
diff --git a/cg-cat b/cg-cat
new file mode 100755
--- /dev/null
+++ b/cg-cat
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Cat a file(s) by filename from a GIT repository.
+
+# Initiated from a request from:		    erg@research.att.com
+#   for an equivalent to "cvs co -p <filename>"
+# Question posted with really bad initial solution: ellson@research.att.com
+# Suggestions offered by:			    Johannes.Schindelin@gmx.de
+#						    rene.scharfe@lsrfire.ath.cx
+# This solution based on posting from:		    torvalds@osdl.org
+# Polish and test by:				    ellson@research.att.com
+
+USAGE="cg-cat [-r rev] FILE"
+
+. ${COGITO_LIB}cg-Xlib
+
+default=HEAD
+while optparse; do
+	if optparse -r; then
+		default="$OPTARG"
+	else
+		optfail
+	fi
+done
+
+[ "$ARGS" ] || usage
+
+git-ls-tree $(git-rev-parse --default $default "${ARGS[@]}") |
+	while read mode type sha name
+	do
+		case "$type" in
+		blob)
+			git-cat-file blob "$sha"
+			;;
+		tree)
+			git-ls-tree "$sha"
+			;;
+		*)
+			exit 1
+			;;
+		esac
+	done

  reply	other threads:[~2005-08-10 14:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-09 21:59 Newbie question: equiv of: cvs co -p <filename> ? John Ellson
2005-08-09 22:10 ` Johannes Schindelin
2005-08-09 22:18   ` Rene Scharfe
2005-08-10  0:36 ` Linus Torvalds
2005-08-10 14:38   ` John Ellson [this message]
2005-08-11 23:03     ` [PATCH] cg-cat [was: Re: Newbie question: equiv of: cvs co -p <filename> ? ] Petr Baudis
2005-08-12  7:53       ` Matthias Urlichs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42FA1150.7090506@research.att.com \
    --to=ellson@research.att.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.