{"thread":{"id":"9522","subject":"[PATCH] Add read_cache to builtin-check-attr","startedAt":"2007-08-14T13:18:38Z","lastAt":"2007-08-15T05:45:57Z","messageCount":8,"participants":["Brian Downing","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50700","messageId":"11870975181798-git-send-email-bdowning@lavos.net","threadId":"9522","inReplyTo":null,"subject":"[PATCH] Add read_cache to builtin-check-attr","fromName":"Brian Downing","fromEmail":"bdowning@lavos.net","sentAt":"2007-08-14T13:18:38Z","receivedAt":"2007-08-14T13:18:38Z","isPatch":true,"sender":{"key":"bdowning@lavos.net","avatar":"https://avatars.githubusercontent.com/u/366426?v=4"},"body":"We can now read .gitattributes files out of the index, but the index\nmust be loaded for this to work.\n\nSigned-off-by: Brian Downing <bdowning@lavos.net>\n---\n builtin-check-attr.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-check-attr.c b/builtin-check-attr.c\nindex 9d77f76..d949733 100644\n--- a/builtin-check-attr.c\n+++ b/builtin-check-attr.c\n@@ -1,4 +1,5 @@\n #include \"builtin.h\"\n+#include \"cache.h\"\n #include \"attr.h\"\n #include \"quote.h\"\n \n@@ -10,6 +11,10 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)\n \tstruct git_attr_check *check;\n \tint cnt, i, doubledash;\n \n+\tif (read_cache() < 0) {\n+\t\tdie(\"invalid cache\");\n+\t}\n+\n \tdoubledash = -1;\n \tfor (i = 1; doubledash < 0 && i < argc; i++) {\n \t\tif (!strcmp(argv[i], \"--\"))\n-- \n1.5.3.GIT\n"},{"id":"50701","messageId":"20070814132209.GJ21692@lavos.net","threadId":"9522","inReplyTo":"11870975181798-git-send-email-bdowning@lavos.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Brian Downing","fromEmail":"bdowning@lavos.net","sentAt":"2007-08-14T13:22:09Z","receivedAt":"2007-08-14T13:22:09Z","isPatch":true,"sender":{"key":"bdowning@lavos.net","avatar":"https://avatars.githubusercontent.com/u/366426?v=4"},"body":"On Tue, Aug 14, 2007 at 08:18:38AM -0500, Brian Downing wrote:\n> We can now read .gitattributes files out of the index, but the index\n> must be loaded for this to work.\n\nThis was supposed to be In-Reply-To Junio's patch, \"attr.c: read\n.gitattributes from index as well.\"  It's not much use without it.\n\n-bcd\n"},{"id":"50704","messageId":"Pine.LNX.4.64.0708141506260.25989@racer.site","threadId":"9522","inReplyTo":"20070814132209.GJ21692@lavos.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-14T14:08:52Z","receivedAt":"2007-08-14T14:08:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 14 Aug 2007, Brian Downing wrote:\n\n> On Tue, Aug 14, 2007 at 08:18:38AM -0500, Brian Downing wrote:\n> > We can now read .gitattributes files out of the index, but the index\n> > must be loaded for this to work.\n> \n> This was supposed to be In-Reply-To Junio's patch, \"attr.c: read\n> .gitattributes from index as well.\"  It's not much use without it.\n\nShouldn't read_cache() be _only_ called if\n\n- it has not been read yet, and\n- .gitattributes was not found in the work tree?\n\nIOW check-attr is the wrong place for your patch IMHO.\n\nCiao,\nDscho\n"},{"id":"50706","messageId":"20070814142428.GK21692@lavos.net","threadId":"9522","inReplyTo":"Pine.LNX.4.64.0708141506260.25989@racer.site","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Brian Downing","fromEmail":"bdowning@lavos.net","sentAt":"2007-08-14T14:24:29Z","receivedAt":"2007-08-14T14:24:29Z","isPatch":true,"sender":{"key":"bdowning@lavos.net","avatar":"https://avatars.githubusercontent.com/u/366426?v=4"},"body":"On Tue, Aug 14, 2007 at 03:08:52PM +0100, Johannes Schindelin wrote:\n> Shouldn't read_cache() be _only_ called if\n> \n> - it has not been read yet, and\n> - .gitattributes was not found in the work tree?\n> \n> IOW check-attr is the wrong place for your patch IMHO.\n\nI admit I just cargo-culted what builtin-checkout-index did upon starting.\nOff the cuff, though, I don't see how the cache could ever already be\nloaded upon the start of cmd_check_attr, and the way the attr.c code is\nwritten, the cache be loaded when we check attributes or it will default\nto the old behavior (only checking the working directory.)\n\nWhat would you suggest here?\n\n-bcd\n"},{"id":"50708","messageId":"Pine.LNX.4.64.0708141540420.25989@racer.site","threadId":"9522","inReplyTo":"20070814142428.GK21692@lavos.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-14T14:46:57Z","receivedAt":"2007-08-14T14:46:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 14 Aug 2007, Brian Downing wrote:\n\n> On Tue, Aug 14, 2007 at 03:08:52PM +0100, Johannes Schindelin wrote:\n> > Shouldn't read_cache() be _only_ called if\n> > \n> > - it has not been read yet, and\n> > - .gitattributes was not found in the work tree?\n> > \n> > IOW check-attr is the wrong place for your patch IMHO.\n> \n> I admit I just cargo-culted what builtin-checkout-index did upon starting.\n> Off the cuff, though, I don't see how the cache could ever already be\n> loaded upon the start of cmd_check_attr,\n\nRight.  I was talking more about read_cache() being called later anyway, \nso you do not have to read the cache if a .gitattributes is there and you \ndo not need the index to begin with.\n\n> and the way the attr.c code is\n> written, the cache be loaded when we check attributes or it will default\n> to the old behavior (only checking the working directory.)\n\nWhy not just make sure that the index is read in read_index_data()?  \nSomething like\n\n\t/* read index if that was not already done yet */\n\tif (!istate->mmap)\n\t\tread_index(&istate);\n\n(Yes, I know that read_index() calls read_index_from(), which in turn \nchecks that, but read_attr() is called possibly pretty often, right?  So \nwe might just as well spare a few cycles here.)\n\nCiao,\nDscho\n"},{"id":"50716","messageId":"7vhcn2c673.fsf@assigned-by-dhcp.cox.net","threadId":"9522","inReplyTo":"11870975181798-git-send-email-bdowning@lavos.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-14T18:38:24Z","receivedAt":"2007-08-14T18:38:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Downing <bdowning@lavos.net> writes:\n\n> We can now read .gitattributes files out of the index, but the index\n> must be loaded for this to work.\n\nThat interface is at too low a level, I am afraid.  Many\ncommands do want to control when they read the index and it\naffects the result, especially when the work tree traversal\nimplemented in dir.c is involved.\n\nI am not rejecting/objecting, but just raising concerns.  I do\nnot have time to review this today, but just wanted to see if\nyou fully assessed the implications (and if so that would save\nwork on my end).\n"},{"id":"50718","messageId":"20070814184541.GL21692@lavos.net","threadId":"9522","inReplyTo":"7vhcn2c673.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Brian Downing","fromEmail":"bdowning@lavos.net","sentAt":"2007-08-14T18:45:41Z","receivedAt":"2007-08-14T18:45:41Z","isPatch":true,"sender":{"key":"bdowning@lavos.net","avatar":"https://avatars.githubusercontent.com/u/366426?v=4"},"body":"On Tue, Aug 14, 2007 at 11:38:24AM -0700, Junio C Hamano wrote:\n> That interface is at too low a level, I am afraid.  Many\n> commands do want to control when they read the index and it\n> affects the result, especially when the work tree traversal\n> implemented in dir.c is involved.\n> \n> I am not rejecting/objecting, but just raising concerns.  I do\n> not have time to review this today, but just wanted to see if\n> you fully assessed the implications (and if so that would save\n> work on my end).\n\nI really don't understand the implications.  That was just something\nthat got it working on my end, and I figured I should send it along\nin case it was just that simple.\n\n-bcd\n"},{"id":"50752","messageId":"7veji5jqp6.fsf@assigned-by-dhcp.cox.net","threadId":"9522","inReplyTo":"20070814184541.GL21692@lavos.net","subject":"Re: [PATCH] Add read_cache to builtin-check-attr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-15T05:45:57Z","receivedAt":"2007-08-15T05:45:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ah, silly me.  The patch was to builtin-check-attr.  I somehow\nthought it was to attr.c::git_checkattr().\n\nThanks, will apply.\n"}]}