{"thread":{"id":"31978","subject":"[PATCH] update-index/diff-index: use core.preloadindex to improve performance","startedAt":"2012-10-30T09:50:42Z","lastAt":"2012-11-13T21:51:46Z","messageCount":9,"participants":["karsten.blees@dcon.de","Erik Faye-Lund","Albert Krawczyk","Jeff King","Junio C Hamano","Karsten Blees"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"202188","messageId":"OF831F4AE9.23F46743-ONC1257AA7.00353C1F-C1257AA7.00361535@dcon.de","threadId":"31978","inReplyTo":null,"subject":"[PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"","fromEmail":"karsten.blees@dcon.de","sentAt":"2012-10-30T09:50:42Z","receivedAt":"2012-10-30T09:50:42Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"'update-index --refresh' and 'diff-index' (without --cached) don't honor\nthe core.preloadindex setting yet. Porcelain commands using these (such as\ngit [svn] rebase) suffer from this, especially on Windows.\n\nUse read_cache_preload to improve performance.\n\nAdditionally, in builtin/diff.c, don't preload index status if we don't\naccess the working copy (--cached).\n\nResults with msysgit on WebKit repo (2GB in 200k files):\n\n                | update-index | diff-index | rebase\n----------------+--------------+------------+---------\nmsysgit-v1.8.0  |       9.157s |    10.536s | 42.791s\n+ preloadindex  |       9.157s |    10.536s | 28.725s\n+ this patch    |       2.329s |     2.752s | 15.152s\n+ fscache [1]   |       0.731s |     1.171s |  8.877s\n\n[1] https://github.com/kblees/git/tree/kb/fscache-v3\n\nThanks-to: Albert Krawczyk <pro-logic@optusnet.com.au>\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n\nCan also be pulled from: \nhttps://github.com/kblees/git/tree/kb/update-diff-index-preload-upstream\n\nI thought I might send this upstream directly, as its not msysgit related. \nMore performance figures (for msysgit) can be found in this discussion: \nhttps://github.com/pro-logic/git/commit/32c03dd8\n\nCiao,\nKarsten\n\n builtin/diff-index.c   |  8 ++++++--\n builtin/diff.c         | 12 ++++++++----\n builtin/update-index.c |  1 +\n 3 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 2eb32bd..1c737f7 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -41,9 +41,13 @@ int cmd_diff_index(int argc, const char **argv, const \nchar *prefix)\n        if (rev.pending.nr != 1 ||\n            rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)\n                usage(diff_cache_usage);\n-       if (!cached)\n+       if (!cached) {\n                setup_work_tree();\n-       if (read_cache() < 0) {\n+               if (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {\n+                       perror(\"read_cache_preload\");\n+                       return -1;\n+               }\n+       } else if (read_cache() < 0) {\n                perror(\"read_cache\");\n                return -1;\n        }\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 9650be2..198b921 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -130,8 +130,6 @@ static int builtin_diff_index(struct rev_info *revs,\n                        usage(builtin_diff_usage);\n                argv++; argc--;\n        }\n-       if (!cached)\n-               setup_work_tree();\n        /*\n         * Make sure there is one revision (i.e. pending object),\n         * and there is no revision filtering parameters.\n@@ -140,8 +138,14 @@ static int builtin_diff_index(struct rev_info *revs,\n            revs->max_count != -1 || revs->min_age != -1 ||\n            revs->max_age != -1)\n                usage(builtin_diff_usage);\n-       if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {\n-               perror(\"read_cache_preload\");\n+       if (!cached) {\n+               setup_work_tree();\n+               if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {\n+                       perror(\"read_cache_preload\");\n+                       return -1;\n+               }\n+       } else if (read_cache() < 0) {\n+               perror(\"read_cache\");\n                return -1;\n        }\n        return run_diff_index(revs, cached);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 74986bf..ada1dff 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -593,6 +593,7 @@ struct refresh_params {\n static int refresh(struct refresh_params *o, unsigned int flag)\n {\n        setup_work_tree();\n+       read_cache_preload(NULL);\n        *o->has_errors |= refresh_cache(o->flags | flag);\n        return 0;\n }\n-- \n1.8.0.msysgit.0.3.g7d9d98c\n"},{"id":"202189","messageId":"CABPQNSb6QzxxJpoackhzRz19UWwpxjJ6MPEeptTU9Z0bEaAB+A@mail.gmail.com","threadId":"31978","inReplyTo":"OF831F4AE9.23F46743-ONC1257AA7.00353C1F-C1257AA7.00361535@dcon.de","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-10-30T10:15:37Z","receivedAt":"2012-10-30T10:15:37Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Tue, Oct 30, 2012 at 10:50 AM,  <karsten.blees@dcon.de> wrote:\n> 'update-index --refresh' and 'diff-index' (without --cached) don't honor\n> the core.preloadindex setting yet. Porcelain commands using these (such as\n> git [svn] rebase) suffer from this, especially on Windows.\n>\n> Use read_cache_preload to improve performance.\n>\n> Additionally, in builtin/diff.c, don't preload index status if we don't\n> access the working copy (--cached).\n>\n> Results with msysgit on WebKit repo (2GB in 200k files):\n>\n>                 | update-index | diff-index | rebase\n> ----------------+--------------+------------+---------\n> msysgit-v1.8.0  |       9.157s |    10.536s | 42.791s\n> + preloadindex  |       9.157s |    10.536s | 28.725s\n> + this patch    |       2.329s |     2.752s | 15.152s\n> + fscache [1]   |       0.731s |     1.171s |  8.877s\n>\n\nWow, awesome results :)\n\nThis also makes me want to play around with the fscache stuff a bit;\nabout an order of magnitude improvement is quite noticeable :)\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"202263","messageId":"CALKo3jR1S924zwnRUG5df9cKXjFkKCtcUO+WzXzLXif+ee8AiQ@mail.gmail.com","threadId":"31978","inReplyTo":"CABPQNSb6QzxxJpoackhzRz19UWwpxjJ6MPEeptTU9Z0bEaAB+A@mail.gmail.com","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Albert Krawczyk","fromEmail":"pro-logic@optusnet.com.au","sentAt":"2012-10-30T22:50:34Z","receivedAt":"2012-10-30T22:50:34Z","isPatch":true,"sender":{"key":"pro-logic@optusnet.com.au","avatar":null},"body":"> Wow, awesome results :)\n\nThey get even better when used with scripted commands like git svn rebase:\n\n                |  cold | warm | hot\n----------------+-------+------+-----\nmsysgit-v1.8.0  | 7m29s | 36s  | 33s\nthis patch      | 28s   | 14s  | 14\n\nhttps://github.com/pro-logic/git/commit/32c03dd8#commitcomment-2070415\n\nKarsten's code is amazing. Now if only I could figure out a way to spread\nthe love through the rest of the source :)\n\nAlbert\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"202439","messageId":"20121102152616.GD11170@sigill.intra.peff.net","threadId":"31978","inReplyTo":"OF831F4AE9.23F46743-ONC1257AA7.00353C1F-C1257AA7.00361535@dcon.de","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-02T15:26:16Z","receivedAt":"2012-11-02T15:26:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 30, 2012 at 10:50:42AM +0100, karsten.blees@dcon.de wrote:\n\n> 'update-index --refresh' and 'diff-index' (without --cached) don't honor\n> the core.preloadindex setting yet. Porcelain commands using these (such as\n> git [svn] rebase) suffer from this, especially on Windows.\n> \n> Use read_cache_preload to improve performance.\n> \n> Additionally, in builtin/diff.c, don't preload index status if we don't\n> access the working copy (--cached).\n> \n> Results with msysgit on WebKit repo (2GB in 200k files):\n> \n>                 | update-index | diff-index | rebase\n> ----------------+--------------+------------+---------\n> msysgit-v1.8.0  |       9.157s |    10.536s | 42.791s\n> + preloadindex  |       9.157s |    10.536s | 28.725s\n> + this patch    |       2.329s |     2.752s | 15.152s\n> + fscache [1]   |       0.731s |     1.171s |  8.877s\n\nCool numbers. On my quad-core SSD Linux box, I saw a few speedups, too.\nHere are the numbers for \"update-index --refresh\" on the WebKit repo\n(all are wall clock time, best-of-five):\n\n             | before | after\n  -----------+--------+--------\n  cold cache | 4.513s | 2.059s\n  warm cache | 0.252s | 0.164s\n\nNot as dramatic, but still nice. I wonder how a spinning disk would fare\non the cold-cache case, though.  I also tried it with all but one CPU\ndisabled, and the warm cache case was a little bit slower.\n\nStill, I don't think we need to worry about performance regressions,\nbecause people who don't have a setup suitable for it will not turn on\ncore.preloadindex in the first place. And if they have it on, the more\nplaces we use it, probably the better.\n\n-Peff\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"202442","messageId":"20121102153800.GE11170@sigill.intra.peff.net","threadId":"31978","inReplyTo":"20121102152616.GD11170@sigill.intra.peff.net","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-02T15:38:00Z","receivedAt":"2012-11-02T15:38:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Nov 02, 2012 at 11:26:16AM -0400, Jeff King wrote:\n\n> Still, I don't think we need to worry about performance regressions,\n> because people who don't have a setup suitable for it will not turn on\n> core.preloadindex in the first place. And if they have it on, the more\n> places we use it, probably the better.\n\nBTW, your patch was badly damaged in transit (wrapped, and tabs\nconverted to spaces). I was able to fix it up, but please check your\nmailer's settings.\n\n-Peff\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"203091","messageId":"OF88D51EE0.C9BFCE98-ONC1257AB5.005493C9-C1257AB5.00557CDD@dcon.de","threadId":"31978","inReplyTo":"20121102152616.GD11170@sigill.intra.peff.net","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"","fromEmail":"karsten.blees@dcon.de","sentAt":"2012-11-13T15:33:43Z","receivedAt":"2012-11-13T15:33:43Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Jeff King <peff@peff.net> wrote on 02.11.2012 16:26:16:\n\n> On Tue, Oct 30, 2012 at 10:50:42AM +0100, karsten.blees@dcon.de wrote:\n> \n> > 'update-index --refresh' and 'diff-index' (without --cached) don't \nhonor\n> > the core.preloadindex setting yet. Porcelain commands using these \n(such as\n> > git [svn] rebase) suffer from this, especially on Windows.\n> > \n> > Use read_cache_preload to improve performance.\n> > \n> > Additionally, in builtin/diff.c, don't preload index status if we \ndon't\n> > access the working copy (--cached).\n> > \n> > Results with msysgit on WebKit repo (2GB in 200k files):\n> > \n> >                 | update-index | diff-index | rebase\n> > ----------------+--------------+------------+---------\n> > msysgit-v1.8.0  |       9.157s |    10.536s | 42.791s\n> > + preloadindex  |       9.157s |    10.536s | 28.725s\n> > + this patch    |       2.329s |     2.752s | 15.152s\n> > + fscache [1]   |       0.731s |     1.171s |  8.877s\n> \n> Cool numbers. On my quad-core SSD Linux box, I saw a few speedups, too.\n> Here are the numbers for \"update-index --refresh\" on the WebKit repo\n> (all are wall clock time, best-of-five):\n> \n>              | before | after\n>   -----------+--------+--------\n>   cold cache | 4.513s | 2.059s\n>   warm cache | 0.252s | 0.164s\n>\n\nGreat, and thanks for testing on Linux (I only have Linux VMs for testing, \nand I couldn't get meaningful performance data from those).\n \n> Not as dramatic, but still nice. I wonder how a spinning disk would fare\n> on the cold-cache case, though.  I also tried it with all but one CPU\n> disabled, and the warm cache case was a little bit slower.\n> \n\nUnfortunately, with a 'real' disk, cold cache times increase with the \nnumber of threads. I've played around with '#define MAX_PARALLEL 20' in \npreload-index.c, with the following results ('git update-index --refresh' \non WebKit repo, Win7 x64, Core i7 860 (2.8GHz 4 Core HT), WD VelociRaptor \n(300G 10krpm 8ms), msysgit 1.8.0 + preload-index patch + fscache patch):\n\nMAX_PARALLEL | cold cache | warm cache\n-------------+------------+------------\nno preload   |     49.938 |     9.204 (*)\n           1 |     45.412 |     1.622\n           2 |     55.334 |     1.123\n           3 |     65.973 |     0.982\n           4 |     67.579 |     0.889\n           5 |     76.159 |     0.827\n           6 |     81.510 |     0.811\n           7 |     86.269 |     0.858\n           8 |     85.862 |     0.827\n        ...\n          10 |     87.953 |     0.717\n        ...\n          20 |    176.251 |     0.749\n\n(*) core.preloadindex currently also disables fscache, thus the 9s\n\nWith more threads, Windows resource monitor also shows increasing disk \nqueue length and response times.\n\nIt seems clear that more concurrent disk seeks hurt cold cache performance \npretty badly. On the other hand, warm cache improvements for #threads > \n#cores are only about 10 - 20%.\n\nI don't know if Linux is better at caching / prefetching directory \nlistings (might depend on file system, too), but perhaps MAX_PARALLEL \nshould be set to a more reasonable value, or be made configurable (e.g. \ncore.preloadIndexThreads)?\n\nKarsten\n"},{"id":"203092","messageId":"OF27D0F811.18A373FB-ONC1257AB5.0055809D-C1257AB5.0055B47D@dcon.de","threadId":"31978","inReplyTo":"20121102153800.GE11170@sigill.intra.peff.net","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"","fromEmail":"karsten.blees@dcon.de","sentAt":"2012-11-13T15:36:06Z","receivedAt":"2012-11-13T15:36:06Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Jeff King <peff@peff.net> wrote on 02.11.2012 16:38:00:\n\n> On Fri, Nov 02, 2012 at 11:26:16AM -0400, Jeff King wrote:\n> \n> > Still, I don't think we need to worry about performance regressions,\n> > because people who don't have a setup suitable for it will not turn on\n> > core.preloadindex in the first place. And if they have it on, the more\n> > places we use it, probably the better.\n> \n> BTW, your patch was badly damaged in transit (wrapped, and tabs\n> converted to spaces). I was able to fix it up, but please check your\n> mailer's settings.\n> \n\nYes, I feared as much, that's why I included the pull URL (the company MTA \nonly accepts outbound mail from Notes clients, sorry).\n\nIs there a policy for people with broken mailers (send patch as \nattachment, add pull URL more prominently, don't include plaintext patch \nat all...)?\n"},{"id":"203106","messageId":"7v4nktfo35.fsf@alter.siamese.dyndns.org","threadId":"31978","inReplyTo":"OF27D0F811.18A373FB-ONC1257AB5.0055809D-C1257AB5.0055B47D@dcon.de","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-13T16:46:06Z","receivedAt":"2012-11-13T16:46:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"karsten.blees@dcon.de writes:\n\n> Jeff King <peff@peff.net> wrote on 02.11.2012 16:38:00:\n>\n>> On Fri, Nov 02, 2012 at 11:26:16AM -0400, Jeff King wrote:\n>> \n>> > Still, I don't think we need to worry about performance regressions,\n>> > because people who don't have a setup suitable for it will not turn on\n>> > core.preloadindex in the first place. And if they have it on, the more\n>> > places we use it, probably the better.\n>> \n>> BTW, your patch was badly damaged in transit (wrapped, and tabs\n>> converted to spaces). I was able to fix it up, but please check your\n>> mailer's settings.\n>> \n>\n> Yes, I feared as much, that's why I included the pull URL (the company MTA \n> only accepts outbound mail from Notes clients, sorry).\n>\n> Is there a policy for people with broken mailers (send patch as \n> attachment, add pull URL more prominently, don't include plaintext patch \n> at all...)?\n\nIf anything, \"fix your mailer\" probably is the policy you are\nlooking for, I think.\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"},{"id":"203150","messageId":"50A2C0F2.20606@gmail.com","threadId":"31978","inReplyTo":"7v4nktfo35.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] update-index/diff-index: use core.preloadindex to improve performance","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2012-11-13T21:51:46Z","receivedAt":"2012-11-13T21:51:46Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 13.11.2012 17:46, schrieb Junio C Hamano:\n> karsten.blees@dcon.de writes:\n> \n> If anything, \"fix your mailer\" probably is the policy you are\n> looking for, I think.\n\nWell then...I've cloned myself @gmail, I hope this is better.\n\nJust some provoking thoughts...(if I may):\n\nRFC-5322 recommends wrapping lines at 78, and mail relays and gateways are allowed to change message content according to the capabilities of the receiver (RFC-5598). In essence, plaintext mail is completely unsuitable for preformatted text such as source code.\n\nOn the other hand, git tries to solve the very problem of distributed source code management, and consistency by strong sha-1 checksums is on the top of the feature list.\n\nIt is somehow hard to believe that contributing to git itself should only be possible using the most unreliable of protocols. Don't you trust your own software?\n\n\n-- >8 --\nSubject: [PATCH] update-index/diff-index: use core.preloadindex to improve performance\n\n'update-index --refresh' and 'diff-index' (without --cached) don't honor\nthe core.preloadindex setting yet. Porcelain commands using these (such as\ngit [svn] rebase) suffer from this, especially on Windows.\n\nUse read_cache_preload to improve performance.\n\nAdditionally, in builtin/diff.c, don't preload index status if we don't\naccess the working copy (--cached).\n\nResults with msysgit on WebKit repo (2GB in 200k files):\n\n                | update-index | diff-index | rebase\n----------------+--------------+------------+---------\nmsysgit-v1.8.0  |       9.157s |    10.536s | 42.791s\n+ preloadindex  |       9.157s |    10.536s | 28.725s\n+ this patch    |       2.329s |     2.752s | 15.152s\n+ fscache [1]   |       0.731s |     1.171s |  8.877s\n\n[1] https://github.com/kblees/git/tree/kb/fscache-v3\n\nThanks-to: Albert Krawczyk <pro-logic@optusnet.com.au>\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n\nCan also be pulled from: https://github.com/kblees/git/tree/kb/update-diff-index-preload-upstream\n\nMore performance figures (for msysgit) can be found in this discussion: https://github.com/pro-logic/git/commit/32c03dd8\n\n\n builtin/diff-index.c   |  8 ++++++--\n builtin/diff.c         | 12 ++++++++----\n builtin/update-index.c |  1 +\n 3 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/diff-index.c b/builtin/diff-index.c\nindex 2eb32bd..1c737f7 100644\n--- a/builtin/diff-index.c\n+++ b/builtin/diff-index.c\n@@ -41,9 +41,13 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \tif (rev.pending.nr != 1 ||\n \t    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)\n \t\tusage(diff_cache_usage);\n-\tif (!cached)\n+\tif (!cached) {\n \t\tsetup_work_tree();\n-\tif (read_cache() < 0) {\n+\t\tif (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {\n+\t\t\tperror(\"read_cache_preload\");\n+\t\t\treturn -1;\n+\t\t}\n+\t} else if (read_cache() < 0) {\n \t\tperror(\"read_cache\");\n \t\treturn -1;\n \t}\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 9650be2..198b921 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -130,8 +130,6 @@ static int builtin_diff_index(struct rev_info *revs,\n \t\t\tusage(builtin_diff_usage);\n \t\targv++; argc--;\n \t}\n-\tif (!cached)\n-\t\tsetup_work_tree();\n \t/*\n \t * Make sure there is one revision (i.e. pending object),\n \t * and there is no revision filtering parameters.\n@@ -140,8 +138,14 @@ static int builtin_diff_index(struct rev_info *revs,\n \t    revs->max_count != -1 || revs->min_age != -1 ||\n \t    revs->max_age != -1)\n \t\tusage(builtin_diff_usage);\n-\tif (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {\n-\t\tperror(\"read_cache_preload\");\n+\tif (!cached) {\n+\t\tsetup_work_tree();\n+\t\tif (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {\n+\t\t\tperror(\"read_cache_preload\");\n+\t\t\treturn -1;\n+\t\t}\n+\t} else if (read_cache() < 0) {\n+\t\tperror(\"read_cache\");\n \t\treturn -1;\n \t}\n \treturn run_diff_index(revs, cached);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 74986bf..ada1dff 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -593,6 +593,7 @@ struct refresh_params {\n static int refresh(struct refresh_params *o, unsigned int flag)\n {\n \tsetup_work_tree();\n+\tread_cache_preload(NULL);\n \t*o->has_errors |= refresh_cache(o->flags | flag);\n \treturn 0;\n }\n-- \n1.8.0.msysgit.0.3.g7d9d98c\n\n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n"}]}