{"thread":{"id":"39178","subject":"'git show' with multiple revisions","startedAt":"2015-04-28T10:10:52Z","lastAt":"2015-04-29T16:08:14Z","messageCount":7,"participants":["Ed Avis","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"260121","messageId":"loom.20150428T120412-982@post.gmane.org","threadId":"39178","inReplyTo":null,"subject":"'git show' with multiple revisions","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-04-28T10:10:52Z","receivedAt":"2015-04-28T10:10:52Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"I would like to see the content of a file in multiple revisions.\nI can get them with 'git show' as follows:\n\n    % git show REV1:FILE\n    % git show REV2:FILE\n\nand so on.  But that launches a new process for each revision.  Now, there is\nthe option to pass multiple arguments to 'git show':\n\n    % git show REV1:FILE REV2:FILE\n\nThis gets both revisions in a single process and so is faster.  But it\nconcatenates the content so there isn't a way to separate them out again.\n\nCould 'git show' sprout an option to get multiple things programmatically\nso that they can be separated out again?  One way would be to quote or escape\nthe contents somehow so that the result can be parsed:\n\n    % git show --porcelain REV1:FILE REV2:FILE\n\nThe question is what format should be used to output many strings to stdout.\n\nAn alternative would be to specify an output file:\n\n    % git show --output foo REV1:FILE                        # writes foo\n    % git show --output foo REV1:FILE --output bar REV2:FILE # writes foo, bar\n\nNote that here I am only getting the file content, not log messages or any of\nthe other things which 'git show' can produce.  So perhaps what I really want\nis some kind of 'git cat'.  Or is there another more appropriate tool?\n\nThanks,\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"260154","messageId":"20150429020452.GA873@peff.net","threadId":"39178","inReplyTo":"loom.20150428T120412-982@post.gmane.org","subject":"Re: 'git show' with multiple revisions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-04-29T02:04:52Z","receivedAt":"2015-04-29T02:04:52Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Apr 28, 2015 at 10:10:52AM +0000, Ed Avis wrote:\n\n> Could 'git show' sprout an option to get multiple things programmatically\n> so that they can be separated out again?  One way would be to quote or escape\n> the contents somehow so that the result can be parsed:\n> \n>     % git show --porcelain REV1:FILE REV2:FILE\n>\n> [...]\n>\n> Note that here I am only getting the file content, not log messages or any of\n> the other things which 'git show' can produce.  So perhaps what I really want\n> is some kind of 'git cat'.  Or is there another more appropriate tool?\n\nI think you want `git cat-file`:\n\n  {\n\techo REV1:FILE\n\techo REV2:FILE\n  } |\n  git cat-file --batch\n\nThis prints a header line for each output object which contains the size\nof the object (so a parser reads a header line, then N bytes, then a\nheader line, N bytes, and so on).\n\n-Peff\n"},{"id":"260177","messageId":"loom.20150429T174544-7@post.gmane.org","threadId":"39178","inReplyTo":"20150429020452.GA873@peff.net","subject":"Re: 'git show' with multiple revisions","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-04-29T15:47:33Z","receivedAt":"2015-04-29T15:47:33Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"Jeff King <peff <at> peff.net> writes:\n\n>I think you want `git cat-file`:\n>\n>  {\n>\techo REV1:FILE\n>\techo REV2:FILE\n>  } |\n>  git cat-file --batch\n>\n>This prints a header line for each output object which contains the size\n>of the object (so a parser reads a header line, then N bytes, then a\n>header line, N bytes, and so on).\n\nThis looks like what I want but the object ids printed appear to be the id\nof the file in a given revision - not the id of the revision itself.\nSo the ids in the output are not the same as the ones in the input.\n\nThat's fine, as long as I can assume that the output entries are in the same\norder as the input?\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"260179","messageId":"20150429155309.GB13518@peff.net","threadId":"39178","inReplyTo":"loom.20150429T174544-7@post.gmane.org","subject":"Re: 'git show' with multiple revisions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-04-29T15:53:10Z","receivedAt":"2015-04-29T15:53:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Apr 29, 2015 at 03:47:33PM +0000, Ed Avis wrote:\n\n> Jeff King <peff <at> peff.net> writes:\n> \n> >I think you want `git cat-file`:\n> >\n> >  {\n> >\techo REV1:FILE\n> >\techo REV2:FILE\n> >  } |\n> >  git cat-file --batch\n> >\n> >This prints a header line for each output object which contains the size\n> >of the object (so a parser reads a header line, then N bytes, then a\n> >header line, N bytes, and so on).\n> \n> This looks like what I want but the object ids printed appear to be the id\n> of the file in a given revision - not the id of the revision itself.\n> So the ids in the output are not the same as the ones in the input.\n\nCorrect. You are feeding a name which resolves to the blob sha1, so\nthat's what cat-file will output for the object id.\n\n> That's fine, as long as I can assume that the output entries are in the same\n> order as the input?\n\nYes, it will process and output them in order.\n\n-Peff\n"},{"id":"260180","messageId":"xmqqtwvz53t7.fsf@gitster.dls.corp.google.com","threadId":"39178","inReplyTo":"loom.20150429T174544-7@post.gmane.org","subject":"Re: 'git show' with multiple revisions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-29T15:53:24Z","receivedAt":"2015-04-29T15:53:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ed Avis <eda@waniasset.com> writes:\n\n> Jeff King <peff <at> peff.net> writes:\n>\n>>I think you want `git cat-file`:\n>>\n>>  {\n>>\techo REV1:FILE\n>>\techo REV2:FILE\n>>  } |\n>>  git cat-file --batch\n>>\n>>This prints a header line for each output object which contains the size\n>>of the object (so a parser reads a header line, then N bytes, then a\n>>header line, N bytes, and so on).\n>\n> This looks like what I want but the object ids printed appear to be the id\n> of the file in a given revision - not the id of the revision itself.\n> So the ids in the output are not the same as the ones in the input.\n\nActually you are asking for REV1:FILE and REV2:FILE, and you are\ngetting these object IDs in the output (you are not asking for REV1\nor REV2 henace you will not see these commit object IDs).\n\n\"cat-file --batch\" will give you the objects in the order you ask.\nI _think_ you can even do that interactively (i.e. you spawn the\nprocess, you feed one object name to its input, you consume its\noutput by reading the header and then given number of bytes, and\nthen you feed the next object name to its input, and so on) without\ndeadlocking yourself.\n"},{"id":"260181","messageId":"loom.20150429T175626-211@post.gmane.org","threadId":"39178","inReplyTo":"xmqqtwvz53t7.fsf@gitster.dls.corp.google.com","subject":"Re: 'git show' with multiple revisions","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-04-29T16:01:41Z","receivedAt":"2015-04-29T16:01:41Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"Junio C Hamano <gitster <at> pobox.com> writes:\n\n>\"cat-file --batch\" will give you the objects in the order you ask.\n\nThanks, that makes it easy to deal with.  In fact, I might prefer to use\ngit cat-file --batch-check and then use some other library to fetch the blob\ncontents.\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"260182","messageId":"xmqqpp6m6hox.fsf@gitster.dls.corp.google.com","threadId":"39178","inReplyTo":"loom.20150429T175626-211@post.gmane.org","subject":"Re: 'git show' with multiple revisions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-29T16:08:14Z","receivedAt":"2015-04-29T16:08:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ed Avis <eda@waniasset.com> writes:\n\n> Junio C Hamano <gitster <at> pobox.com> writes:\n>\n>>\"cat-file --batch\" will give you the objects in the order you ask.\n>\n> Thanks, that makes it easy to deal with.  In fact, I might prefer to use\n> git cat-file --batch-check and then use some other library to fetch the blob\n> contents.\n\nIf all you need is a translation from extended SHA-1 object name\nlike HEAD~243:Documentation/README to the raw 40-hex object name,\n\"rev-parse\" may turn out to be more suitable tool than that.\n\nIt of course depends on your use case.\n"}]}