{"thread":{"id":"1465","subject":"Newbie question: equiv of: cvs co -p <filename> ?","startedAt":"2005-08-09T21:59:14Z","lastAt":"2005-08-12T07:53:12Z","messageCount":7,"participants":["John Ellson","Johannes Schindelin","Rene Scharfe","Linus Torvalds","Petr Baudis","Matthias Urlichs"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"7010","messageId":"ddb8vl$ifq$1@sea.gmane.org","threadId":"1465","inReplyTo":null,"subject":"Newbie question: equiv of: cvs co -p <filename> ?","fromName":"John Ellson","fromEmail":"ellson@research.att.com","sentAt":"2005-08-09T21:59:14Z","receivedAt":"2005-08-09T21:59:14Z","isPatch":false,"sender":{"key":"ellson@research.att.com","avatar":null},"body":"How can we cat the latest committed state of a file to stdout?\n\nI hacked this:\n\n\t#!/bin/bash\n\tID=`git-ls-files -s | grep $1 | cut -d ' ' -f 2`\n\tTMP=`git-unpack-file $ID`\n\tcat $TMP\n\trm $TMP\n\nbut its really ugly!   It must be easier than this?\n\nJohn\n"},{"id":"7011","messageId":"Pine.LNX.4.63.0508100009210.10311@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1465","inReplyTo":"ddb8vl$ifq$1@sea.gmane.org","subject":"Re: Newbie question: equiv of: cvs co -p <filename> ?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-09T22:10:02Z","receivedAt":"2005-08-09T22:10:02Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 9 Aug 2005, John Ellson wrote:\n\n> How can we cat the latest committed state of a file to stdout?\n> \n> I hacked this:\n> \n> \t#!/bin/bash\n> \tID=`git-ls-files -s | grep $1 | cut -d ' ' -f 2`\n\nand now:\n\n\tgit-cat-file blob $ID\n\nVoila,\nDscho\n"},{"id":"7013","messageId":"42F92BC2.20406@lsrfire.ath.cx","threadId":"1465","inReplyTo":"Pine.LNX.4.63.0508100009210.10311@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: Newbie question: equiv of: cvs co -p <filename> ?","fromName":"Rene Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2005-08-09T22:18:42Z","receivedAt":"2005-08-09T22:18:42Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Johannes Schindelin wrote:\n> On Tue, 9 Aug 2005, John Ellson wrote:\n>>How can we cat the latest committed state of a file to stdout?\n>>\n>>I hacked this:\n>>\n>>\t#!/bin/bash\n>>\tID=`git-ls-files -s | grep $1 | cut -d ' ' -f 2`\n> \n> \n> and now:\n> \n> \tgit-cat-file blob $ID\n\nStill not pretty.  How about this?\n\n\t#!/bin/sh\n\tgit-ls-tree HEAD \"$@\" | while read mode type hash filename; do\n\t\t[ \"$type\" = \"blob\" ] && git-cat-file blob \"$hash\"\n\tdone\n\nRene\n"},{"id":"7017","messageId":"Pine.LNX.4.58.0508091725120.3258@g5.osdl.org","threadId":"1465","inReplyTo":"ddb8vl$ifq$1@sea.gmane.org","subject":"Re: Newbie question: equiv of: cvs co -p <filename> ?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-10T00:36:09Z","receivedAt":"2005-08-10T00:36:09Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 9 Aug 2005, John Ellson wrote:\n> \n> I hacked this:\n> \n> \t#!/bin/bash\n> \tID=`git-ls-files -s | grep $1 | cut -d ' ' -f 2`\n\nNo. \"git-ls-files\" shows the latest _index_ state, not the latest \ncommitted state.\n\nUse \"git-ls-tree HEAD pathname\" to get the latest committed state for the \npathname, and then pick out the SHA1 from there, use\n\n\tgit-cat-file blob <sha1>\n\nto cat the result.\n\nOf course, this will work with any revision, not just HEAD. So you could \ndo something like\n\n\tgit-ls-tree $(git-rev-parse --default HEAD \"$@\") |\n\t\twhile read mode type sha name\n\t\tdo\n\t\t\tcase \"$type\" in\n\t\t\tblob)\n\t\t\t\tgit-cat-file blob \"$sha\"\n\t\t\t\t;;\n\t\t\ttree)\n\t\t\t\tgit-ls-tree \"$sha\"\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\texit 1\n\t\tdone\n\n(totally untested)\n\n\t\tLinus\n"},{"id":"7026","messageId":"42FA1150.7090506@research.att.com","threadId":"1465","inReplyTo":"Pine.LNX.4.58.0508091725120.3258@g5.osdl.org","subject":"[PATCH] cg-cat [was: Re: Newbie question: equiv of: cvs co -p <filename> ? ]","fromName":"John Ellson","fromEmail":"ellson@research.att.com","sentAt":"2005-08-10T14:38:08Z","receivedAt":"2005-08-10T14:38:08Z","isPatch":true,"sender":{"key":"ellson@research.att.com","avatar":null},"body":"Linus Torvalds wrote:\n> \n> On Tue, 9 Aug 2005, John Ellson wrote:\n> \n>>I hacked this:\n\n> No. ...\n\n> So you could do something like ...\n\n> (totally untested)\n> \n> \t\tLinus\n\n\nThanks Linus, also Rene and Johannes.\n\nI applied a bit of polish and testing and now I'm ready to offer\nmy first contribution to cogito.\n\n\tcg-cat [-r rev] FILE\n\nI hope that this is useful to others.\n\n\nSigned-off-by: John Ellson <ellson@research.att.com>\n\n---\n\n\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -14,11 +14,11 @@ INSTALL?=install\n \n SCRIPT=\tcommit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \\\n \tcg-branch-add cg-branch-ls cg-reset cg-clone cg-commit cg-diff \\\n \tcg-export cg-help cg-init cg-log cg-merge cg-mkpatch cg-patch \\\n \tcg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \\\n-\tcg cg-admin-ls cg-push cg-branch-chg\n+\tcg cg-admin-ls cg-push cg-branch-chg cg-cat\n \n LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xnormid\n \n GEN_SCRIPT= cg-version\n \ndiff --git a/cg-cat b/cg-cat\nnew file mode 100755\n--- /dev/null\n+++ b/cg-cat\n@@ -0,0 +1,42 @@\n+#!/bin/sh\n+#\n+# Cat a file(s) by filename from a GIT repository.\n+\n+# Initiated from a request from:\t\t    erg@research.att.com\n+#   for an equivalent to \"cvs co -p <filename>\"\n+# Question posted with really bad initial solution: ellson@research.att.com\n+# Suggestions offered by:\t\t\t    Johannes.Schindelin@gmx.de\n+#\t\t\t\t\t\t    rene.scharfe@lsrfire.ath.cx\n+# This solution based on posting from:\t\t    torvalds@osdl.org\n+# Polish and test by:\t\t\t\t    ellson@research.att.com\n+\n+USAGE=\"cg-cat [-r rev] FILE\"\n+\n+. ${COGITO_LIB}cg-Xlib\n+\n+default=HEAD\n+while optparse; do\n+\tif optparse -r; then\n+\t\tdefault=\"$OPTARG\"\n+\telse\n+\t\toptfail\n+\tfi\n+done\n+\n+[ \"$ARGS\" ] || usage\n+\n+git-ls-tree $(git-rev-parse --default $default \"${ARGS[@]}\") |\n+\twhile read mode type sha name\n+\tdo\n+\t\tcase \"$type\" in\n+\t\tblob)\n+\t\t\tgit-cat-file blob \"$sha\"\n+\t\t\t;;\n+\t\ttree)\n+\t\t\tgit-ls-tree \"$sha\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\texit 1\n+\t\t\t;;\n+\t\tesac\n+\tdone\n"},{"id":"7087","messageId":"20050811230343.GJ25280@pasky.ji.cz","threadId":"1465","inReplyTo":"42FA1150.7090506@research.att.com","subject":"Re: [PATCH] cg-cat [was: Re: Newbie question: equiv of: cvs co -p <filename> ? ]","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-08-11T23:03:43Z","receivedAt":"2005-08-11T23:03:43Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Wed, Aug 10, 2005 at 04:38:08PM CEST, I got a letter\nwhere John Ellson <ellson@research.att.com> told me that...\n> Linus Torvalds wrote:\n> >\n> >On Tue, 9 Aug 2005, John Ellson wrote:\n> >\n> >>I hacked this:\n> \n> >No. ...\n> \n> >So you could do something like ...\n> \n> >(totally untested)\n> >\n> >\t\tLinus\n> \n> \n> Thanks Linus, also Rene and Johannes.\n> \n> I applied a bit of polish and testing and now I'm ready to offer\n> my first contribution to cogito.\n> \n> \tcg-cat [-r rev] FILE\n> \n> I hope that this is useful to others.\n\nThanks, cleaned up and applied. I only renamed it to cg-admin-cat since\nI think it's indeed a bit obscure. Also, note the remarkable similarity:\n\n        cg-admin-cat       [-r TREE_ID] FILE...\n        cg-admin-ls        [-t TREE_ID] [PATH]\n\nWhat about joining those to cg-admin-dig or something? (Catting a\ndirectory or ls'ing file contents just feels wrong, although the first\none would make some sense to people not acquainted with UNIX.)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nIf you want the holes in your knowledge showing up try teaching\nsomeone.  -- Alan Cox\n"},{"id":"7106","messageId":"pan.2005.08.12.07.53.11.741187@smurf.noris.de","threadId":"1465","inReplyTo":"20050811230343.GJ25280@pasky.ji.cz","subject":"Re: [PATCH] cg-cat [was: Re: Newbie question: equiv of: cvs co -p <filename> ? ]","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-08-12T07:53:12Z","receivedAt":"2005-08-12T07:53:12Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi, Petr Baudis wrote:\n\n>         cg-admin-cat       [-r TREE_ID] FILE...\n>         cg-admin-ls        [-t TREE_ID] [PATH]\n\nI don't know if these need to be merged, *but* please at least\nchange one of the flag names so that the whole mess is slightly more\nconsistent.\n\n-- \nMatthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de\nDisclaimer: The quote was selected randomly. Really. | http://smurf.noris.de\n - -\nThe thought of 2000 thousand people munching celery at the same time\nhorrifies me.\n\t\t\t\t\t-- George Bernard Shaw\n"}]}