{"thread":{"id":"21046","subject":"[RFC] 'git cat-file' needs a better design on its option interface","startedAt":"2009-09-24T15:04:31Z","lastAt":"2009-09-25T02:33:21Z","messageCount":6,"participants":["Li Hong","Jeff King","Linus Torvalds","Matthieu Moy","Nicolas Pitre"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123738","messageId":"3a3680030909240804w1399ed7fhd6367300544f34f@mail.gmail.com","threadId":"21046","inReplyTo":null,"subject":"[RFC] 'git cat-file' needs a better design on its option interface","fromName":"Li Hong","fromEmail":"lihong.hi@gmail.com","sentAt":"2009-09-24T15:04:31Z","receivedAt":"2009-09-24T15:04:31Z","isPatch":false,"sender":{"key":"lihong.hi@gmail.com","avatar":null},"body":"Hi All,\n\nWhen using 'git cat-file' recently, I find its option interface is somewhat\ninconvenient or mistakenly-designed.\n\n\t1. There is no default action. You have to use -p or <type> option,\n\teven for a simple look at the content of an object. It is better if\n\twe can provide a default action just like 'cat' does.\n\t\n\t2. Can't control the output. Several output options can't be used at\n\tthe same time. Can't control what to output and how to output. I\n\tsuggest here we use a simple format string to let the human being\n\tand other batch scripts happy.\n\n\t3. Batch mode is handled seperately and differently.\n\n\t4. <type> option has a mix meaning (raw print and object dereference)\n\tand is also inconsistent with -x style option.\n\n\t  * for raw print, an format char such as 'r' should be a good choice.\n\t  * for dereference, should use the uniform rev-naming. (e.g.\n\t    v0.99.8^{commit})\n\n\nSo I propose to amend the interface as follow:\n\n\tgit cat-file [-b] [-f <fmt>] [-e] <args> ...\n\n\t-b\tread more objects from stdin\n\t-f\tprovide a output format string\n\t-e\tsilent, exit with zero when there's no error\n\n\tthe default action is to pretty-print the content when there is no\n\tother options except -b.\n\nA format string example can be formed as follow (this needs more discuss):\n\n\t\"blabla %t\\s%s\\t%h\\n%p\\n%r\\n\\n\"\n\n\t%t: type\n\t%s: size\n\t%h: sha1\n\t%p: pretty-print\n\t%r: raw-print\n\nHowever, this change will give a heavy impact on many documents and scripts\ndepending on this command. There are 233 references in source code according\nto a trivial count 'grep -r \"cat-file\" * | wc -l', not to mention many\nprivate usage of this command.\n\nSo this is just a RFC. If I can get a very positive feedback from the\ncommunity, I may start to do the real code change.\n\nAny ideas?\n\n- Li Hong\n"},{"id":"123741","messageId":"20090924164834.GB5655@coredump.intra.peff.net","threadId":"21046","inReplyTo":"3a3680030909240804w1399ed7fhd6367300544f34f@mail.gmail.com","subject":"Re: [RFC] 'git cat-file' needs a better design on its option interface","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-24T16:48:35Z","receivedAt":"2009-09-24T16:48:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 24, 2009 at 11:04:31PM +0800, Li Hong wrote:\n\n> When using 'git cat-file' recently, I find its option interface is somewhat\n> inconvenient or mistakenly-designed.\n\nYes, the current interface has grown over time and kind of sucks. I\nagree with all of your complaints.\n\nThat being said, the reason it has grown in that way is that as a\nplumbing command, cat-file must retain backwards compatibility so as not\nto break existing scripts which make use of it. And it is not enough to\nlook through git.git and fix all of our scripts; the interface to\ncat-file is a public one, and we must take care not to break other\npeople's custom scripts.\n\nI'm not quite sure where your complaints are coming from. Do you want:\n\n  1. Something more sane to type in your terminal for everyday use? Then\n     you probably want to use (or invent) some sort of user-facing\n     porcelain that does a similar thing. This is mostly covered by \"git\n     show\" these days, but if there is something lacking, proposals\n     describing your use case would be welcome.\n\n  2. To script around cat-file, but there is some action you want to do\n     that is missing from the interface? In that case, can you describe\n     your use case in more detail, and exactly what addition you want to\n     make to the cat-file interface to accomodate it?\n\n  3. To just clean up cruft from the interface for your scripts? I am\n     somewhat sympathetic to wanting a nicer interface. But keep in\n     mind that we have to keep the old interface around to support\n     historical scripts. So while your new interface may be more\n     flexible and less complex, you have to consider whether having\n     _both_ interfaces will actually be less complex in the long run.\n\n-Peff\n"},{"id":"123743","messageId":"alpine.LFD.2.01.0909241021120.3303@localhost.localdomain","threadId":"21046","inReplyTo":"3a3680030909240804w1399ed7fhd6367300544f34f@mail.gmail.com","subject":"Re: [RFC] 'git cat-file' needs a better design on its option interface","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-09-24T17:23:52Z","receivedAt":"2009-09-24T17:23:52Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 24 Sep 2009, Li Hong wrote:\n> \n> When using 'git cat-file' recently, I find its option interface is somewhat\n> inconvenient or mistakenly-designed.\n\nYou likely shouldn't use 'cat-file' at all. Have you looked at 'git show'? \nThat's the command meant for human beings.\n\n'git cat-file' is really really low-level plumbing. Humans should \ngenerally never use it. It's one of the original git commands (it was \nliterally in the original git commit), and it does some really low-level \nstuff that is good for scripting but not for any normal use.\n\n\t\tLinus\n"},{"id":"123747","messageId":"vpqy6o4kv24.fsf@bauges.imag.fr","threadId":"21046","inReplyTo":"alpine.LFD.2.01.0909241021120.3303@localhost.localdomain","subject":"Re: [RFC] 'git cat-file' needs a better design on its option interface","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-24T19:21:39Z","receivedAt":"2009-09-24T19:21:39Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> 'git cat-file' is really really low-level plumbing. Humans should \n> generally never use it.\n\n... except to understand Git better ;-). I enjoyed being able to to a\n'git cat-file' on a tree or commit object when I started with Git.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"123749","messageId":"alpine.LFD.2.00.0909241528110.4997@xanadu.home","threadId":"21046","inReplyTo":"vpqy6o4kv24.fsf@bauges.imag.fr","subject":"Re: [RFC] 'git cat-file' needs a better design on its option interface","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2009-09-24T19:30:32Z","receivedAt":"2009-09-24T19:30:32Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 24 Sep 2009, Matthieu Moy wrote:\n\n> Linus Torvalds <torvalds@linux-foundation.org> writes:\n> \n> > 'git cat-file' is really really low-level plumbing. Humans should \n> > generally never use it.\n> \n> ... except to understand Git better ;-). I enjoyed being able to to a\n> 'git cat-file' on a tree or commit object when I started with Git.\n\nIn the context of learning git at that level, the current option \ninterface for cat-file shouldn't look too strange though.\n\n\nNicolas\n"},{"id":"123752","messageId":"3a3680030909241933g5ac48496ic9673030de81898c@mail.gmail.com","threadId":"21046","inReplyTo":"alpine.LFD.2.01.0909241021120.3303@localhost.localdomain","subject":"Re: [RFC] 'git cat-file' needs a better design on its option interface","fromName":"Li Hong","fromEmail":"lihong.hi@gmail.com","sentAt":"2009-09-25T02:33:21Z","receivedAt":"2009-09-25T02:33:21Z","isPatch":false,"sender":{"key":"lihong.hi@gmail.com","avatar":null},"body":"2009/9/25 Linus Torvalds <torvalds@linux-foundation.org>:\n>\n>\n> On Thu, 24 Sep 2009, Li Hong wrote:\n>>\n>> When using 'git cat-file' recently, I find its option interface is somewhat\n>> inconvenient or mistakenly-designed.\n>\n> You likely shouldn't use 'cat-file' at all. Have you looked at 'git show'?\n> That's the command meant for human beings.\n>\n> 'git cat-file' is really really low-level plumbing. Humans should\n> generally never use it. It's one of the original git commands (it was\n> literally in the original git commit), and it does some really low-level\n> stuff that is good for scripting but not for any normal use.\n>\n>                Linus\n>\n\nYes, I know 'git show' and use it mostly. I just think the interface\nof 'cat-file'\nis not well designed even used by other scripts or porcelains. But from another\nrespect, it doesn't really annoy normal users much and we should retain\nbackwards compatibility. So I give up.\n\nThanks for all your feedbacks.\n\n-Li Hong\n"}]}