{"thread":{"id":"221","subject":"[PATCH 16/19] change all call sites that use the return value of read_cache to get the # of cache entries.","startedAt":"2005-04-21T18:38:36Z","lastAt":"2005-04-21T18:38:36Z","messageCount":1,"participants":["Brad Roberts"],"isPatch":true,"patchVersion":1,"patchTotal":19},"messages":[{"id":"1170","messageId":"200504211838.j3LIcahX027805@gameboy2.puremagic.com","threadId":"221","inReplyTo":null,"subject":"[PATCH 16/19] change all call sites that use the return value of read_cache to get the # of cache entries.","fromName":"Brad Roberts","fromEmail":"braddr@gameboy2.puremagic.com","sentAt":"2005-04-21T18:38:36Z","receivedAt":"2005-04-21T18:38:36Z","isPatch":true,"sender":{"key":"braddr@gameboy2.puremagic.com","avatar":null},"body":"tree 6bce19032505c2939bf74eeca5e51aeefa4e1600\nparent f07f7073f45a7f81e5b6cf26f5181e14fd051d81\nauthor Brad Roberts <braddr@puremagic.com> 1114086602 -0700\ncommitter Brad Roberts <braddr@gameboy2.puremagic.com> 1114086602 -0700\n\n[PATCH] change all call sites that use the return value of read_cache to get the # of cache entries.\n\nThis patch somewhat breaks error handling for those call sites.  I'll fix\nthat in the next few patches.\n\nSigned-off-by: Brad Roberts <braddr@puremagic.com>\n---\n\n show-diff.c    |   13 ++++++++-----\n update-cache.c |    3 ++-\n write-tree.c   |    4 +++-\n 3 files changed, 13 insertions(+), 7 deletions(-)\n\nIndex: show-diff.c\n===================================================================\n--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/show-diff.c  (mode:100644 sha1:e2642b65805b3e52a16c6309b44a92c2a2bd13c3)\n+++ b965055600b8bf4927ea631446cd6cde714aef95:1/show-diff.c  (mode:100644 sha1:6e04e9182667cbb79afa4c878a31b685fdea3229)\n@@ -126,10 +126,17 @@\n \tint silent_on_nonexisting_files = 0;\n \tint machine_readable = 0;\n \tint reverse = 0;\n-\tint entries = read_cache();\n+\tint entries;\n \tint matched = 0;\n \tint i;\n \n+\tread_cache();\n+\tentries = get_num_cache_entries();\n+\tif (entries < 0) {\n+\t\tperror(\"read_cache\");\n+\t\texit(1);\n+\t}\n+\n \twhile (1 < argc && argv[1][0] == '-') {\n \t\tif  (!strcmp(argv[1], \"-R\"))\n \t\t\treverse = 1;\n@@ -147,10 +154,6 @@\n \t/* At this point, if argc == 1, then we are doing everything.\n \t * Otherwise argv[1] .. argv[argc-1] have the explicit paths.\n \t */\n-\tif (entries < 0) {\n-\t\tperror(\"read_cache\");\n-\t\texit(1);\n-\t}\n \tprepare_diff_cmd();\n \tfor (i = 0; i < entries; i++) {\n \t\tstruct stat st;\nIndex: update-cache.c\n===================================================================\n--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/update-cache.c  (mode:100644 sha1:e741f593eb9c56c596fabed7eb6b79dee2d8cba9)\n+++ b965055600b8bf4927ea631446cd6cde714aef95:1/update-cache.c  (mode:100644 sha1:8328975cb726f5e06a413a9f0099bfa2f81d3381)\n@@ -299,7 +299,8 @@\n \tatexit(remove_lock_file);\n \tremove_lock = 1;\n \n-\tentries = read_cache();\n+\tread_cache();\n+\tentries = get_num_cache_entries();\n \tif (entries < 0)\n \t\tdie(\"cache corrupted\");\n \nIndex: write-tree.c\n===================================================================\n--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/write-tree.c  (mode:100644 sha1:f1b12cdde1bb446a134a121760007150008b251a)\n+++ b965055600b8bf4927ea631446cd6cde714aef95:1/write-tree.c  (mode:100644 sha1:92e707fd4780805da160ce6fa282e75111ea67b9)\n@@ -101,9 +101,11 @@\n int main(int argc, char **argv)\n {\n \tint i, unmerged;\n-\tint entries = read_cache();\n+\tint entries;\n \tunsigned char sha1[20];\n \n+\tread_cache();\n+\tentries = get_num_cache_entries();\n \tif (entries <= 0)\n \t\tdie(\"write-tree: no cache contents to write\");\n \n\n"}]}