{"thread":{"id":"6479","subject":"[PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","startedAt":"2007-01-22T20:29:45Z","lastAt":"2007-01-23T03:17:55Z","messageCount":7,"participants":["Peter Eriksen","Simon 'corecode' Schubert","Shawn O. Pearce","Linus Torvalds","Jakub Narebski","Morten Welinder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32328","messageId":"20070122202945.GA29297@bohr.gbar.dtu.dk","threadId":"6479","inReplyTo":null,"subject":"[PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Peter Eriksen","fromEmail":"s022018@student.dtu.dk","sentAt":"2007-01-22T20:29:45Z","receivedAt":"2007-01-22T20:29:45Z","isPatch":true,"sender":{"key":"s022018@student.dtu.dk","avatar":null},"body":"We used to call find_pack_entry() twice from read_sha1_file() in order\nto avoid printing an error message, when the object did not exist.  This\nis fixed by moving the call to error() to the only place it really\ncould be called.\n\nSigned-off-by: Peter Eriksen <s022018@student.dtu.dk>\n---\n sha1_file.c |   19 +++++++++----------\n 1 files changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 3025440..43ff402 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1469,21 +1469,20 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo\n {\n \tstruct pack_entry e;\n \n-\tif (!find_pack_entry(sha1, &e, NULL)) {\n-\t\terror(\"cannot read sha1_file for %s\", sha1_to_hex(sha1));\n+\tif (!find_pack_entry(sha1, &e, NULL))\n \t\treturn NULL;\n-\t}\n-\treturn unpack_entry(e.p, e.offset, type, size);\n+\telse\n+\t\treturn unpack_entry(e.p, e.offset, type, size);\n }\n \n void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size)\n {\n \tunsigned long mapsize;\n \tvoid *map, *buf;\n-\tstruct pack_entry e;\n \n-\tif (find_pack_entry(sha1, &e, NULL))\n-\t\treturn read_packed_sha1(sha1, type, size);\n+\tbuf = read_packed_sha1(sha1, type, size);\n+\tif (buf)\n+\t\treturn buf;\n \tmap = map_sha1_file(sha1, &mapsize);\n \tif (map) {\n \t\tbuf = unpack_sha1_file(map, mapsize, type, size);\n@@ -1491,9 +1490,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size\n \t\treturn buf;\n \t}\n \treprepare_packed_git();\n-\tif (find_pack_entry(sha1, &e, NULL))\n-\t\treturn read_packed_sha1(sha1, type, size);\n-\treturn NULL;\n+\treturn read_packed_sha1(sha1, type, size);\n }\n \n void *read_object_with_reference(const unsigned char *sha1,\n@@ -1781,6 +1778,8 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize)\n \n \t/* need to unpack and recompress it by itself */\n \tunpacked = read_packed_sha1(sha1, type, &len);\n+\tif (!unpacked)\n+\t\terror(\"cannot read sha1_file for %s\", sha1_to_hex(sha1));\n \n \thdrlen = sprintf(hdr, \"%s %lu\", type, len) + 1;\n \n-- \n1.5.0.rc1.gdf1b-dirty\n"},{"id":"32334","messageId":"45B524E1.5060205@fs.ei.tum.de","threadId":"6479","inReplyTo":"20070122202945.GA29297@bohr.gbar.dtu.dk","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Simon 'corecode' Schubert","fromEmail":"corecode@fs.ei.tum.de","sentAt":"2007-01-22T20:56:01Z","receivedAt":"2007-01-22T20:56:01Z","isPatch":true,"sender":{"key":"corecode@fs.ei.tum.de","avatar":"https://gravatar.com/avatar/eff9dbf0cdac0d1e6a6cd7ed0e50763edcb376b493b5253a35ff167918ad79e1?d=mp&s=160"},"body":"Peter Eriksen wrote:\n> We used to call find_pack_entry() twice from read_sha1_file() in order\n> to avoid printing an error message, when the object did not exist.  This\n> is fixed by moving the call to error() to the only place it really\n> could be called.\n> \n> Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>\n\nI noticed this originally, Peter was so kind to come up with a patch.  Reviewed and found +1, so:\n\nSigned-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>\n\ncheers\n  simon\n\n-- \nServe - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /\"\\\nWork - Mac      +++  space for low €€€ NOW!1  +++      Campaign     \\ /\nParty Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \\\nDude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \\\n\n"},{"id":"32338","messageId":"20070122210719.GA29975@spearce.org","threadId":"6479","inReplyTo":"45B524E1.5060205@fs.ei.tum.de","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-22T21:07:19Z","receivedAt":"2007-01-22T21:07:19Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Simon 'corecode' Schubert <corecode@fs.ei.tum.de> wrote:\n> Peter Eriksen wrote:\n> >We used to call find_pack_entry() twice from read_sha1_file() in order\n> >to avoid printing an error message, when the object did not exist.  This\n> >is fixed by moving the call to error() to the only place it really\n> >could be called.\n> >\n> >Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>\n> \n> I noticed this originally, Peter was so kind to come up with a patch.  \n> Reviewed and found +1, so:\n> \n> Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>\n\nWow.  That's ugly.  Thanks for finding and patching it.\n\n-- \nShawn.\n"},{"id":"32353","messageId":"Pine.LNX.4.64.0701221611210.32200@woody.linux-foundation.org","threadId":"6479","inReplyTo":"45B524E1.5060205@fs.ei.tum.de","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-01-23T00:25:14Z","receivedAt":"2007-01-23T00:25:14Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 22 Jan 2007, Simon 'corecode' Schubert wrote:\n> \n> -- \n> Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /\"\\\n> Work - Mac      +++  space for low  NOW!1  +++      Campaign     \\ /\n> Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \\\n> Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \\\n\nWhee. It's been a long time since I saw ascii barfics and posted them to \nalt.fan.warlord, and I doubt the newsgroup even exists any more, but I \nhave to commend you for getting a tab-damaged ascii barfic even without \nusing any TAB characters!\n\nI assume there are three '$$$' characters missing in your banner \nadvertizing space. Maybe an Euro character? The joys of tab-damage just \nexpands in the modern world of new character sets..\n\nFor extra points, please add ascii runes and/or big ascii swords to your \nsignature, to make it truly old-time warlord material.\n\n\t\tLinus \"nostalgic for afw\" Torvalds\n"},{"id":"32354","messageId":"ep3lf6$a9t$1@sea.gmane.org","threadId":"6479","inReplyTo":"Pine.LNX.4.64.0701221611210.32200@woody.linux-foundation.org","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-01-23T00:39:50Z","receivedAt":"2007-01-23T00:39:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> I assume there are three '$$$' characters missing in your banner \n> advertizing space. Maybe an Euro character? The joys of tab-damage just \n> expands in the modern world of new character sets..\n\nI see three euro characters there. I don't know why unknown character\ndidn't got replaced by ? or something like that....\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"32359","messageId":"118833cc0701221810kf817ddcm2bff07f3a848d1c2@mail.gmail.com","threadId":"6479","inReplyTo":"Pine.LNX.4.64.0701221611210.32200@woody.linux-foundation.org","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2007-01-23T02:10:26Z","receivedAt":"2007-01-23T02:10:26Z","isPatch":true,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":">                 Linus \"nostalgic for afw\" Torvalds\n\n>From the \"nostalgic\" department we also have this.  I have no idea if it\nwill survive today's mailing lists.  In any case, a fixed-width font is your\nfriend.  (And I sadly note that linux.cs.helsinki.fi is nowadays refusing\nfinger connections.)\n\nMorten\n(who lost the original attribution -- sorry.  I certainly didn't make\nit myself.)\n\n\n                                   _,-/\"---,\n            ;\"\"\"\"\"\"\"\"\"\";         _/;; \"\"  <@`---v\n          ; :::::  ::  \"\\      _/ ;;  \"    _.../\n         ;\"     ;;  ;;;  \\___/::    ;;,'\"\"\"\"\n        ;\"          ;;;;.  ;;  ;;;  ::/\n       ,/ / ;;  ;;;______;;;  ;;; ::,/\n       /;;V_;;   ;;;       \\       /\n       | :/ / ,/            \\_ \"\")/\n       | | / /\"\"\"=            \\;;\\\"\"=\n       ; ;{::\"\"\"\"\"\"=            \\\"\"\"=\n    ;\"\"\"\";\n    \\/\"\"\"\n         THAT's a weasel, folks!\n\n              Linux 2.0\n"},{"id":"32361","messageId":"Pine.LNX.4.64.0701221909190.32200@woody.linux-foundation.org","threadId":"6479","inReplyTo":"118833cc0701221810kf817ddcm2bff07f3a848d1c2@mail.gmail.com","subject":"Re: [PATCH] sha1_file.c: Avoid multiple calls to find_pack_entry().","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-01-23T03:17:55Z","receivedAt":"2007-01-23T03:17:55Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 22 Jan 2007, Morten Welinder wrote:\n>\n> (And I sadly note that linux.cs.helsinki.fi is nowadays refusing finger \n> connections.)\n\nI think the ascii barfics went away even before I left University due to a \ndead harddisk, and me being too lazy to re-create my changing fingerd and \nall the cruddy ascii art.\n\nI think Helsinki University ended up having a simple finger service for a \nwhile to return the versioning thing (just because it was in too many \nFAQ's to drop entirely), but I don't think the great artwork was ever \nrecreated..\n\n(In all honesty, I don't think it ever really had more than a couple of \npictures - the weasel, the sleeping cat, and some random other ones. \n\"Great art\" it was not..)\n\n\t\tLinus\n"}]}