{"thread":{"id":"759","subject":"[GIT PATCH] Fix git-mktag to take the object input spliced arbitrarily","startedAt":"2005-05-29T18:52:30Z","lastAt":"2005-05-29T18:52:30Z","messageCount":1,"participants":["Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4186","messageId":"20050529185230.GN1036@pasky.ji.cz","threadId":"759","inReplyTo":null,"subject":"[GIT PATCH] Fix git-mktag to take the object input spliced arbitrarily","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-29T18:52:30Z","receivedAt":"2005-05-29T18:52:30Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Before, git-mktag would just try to get all the input through a single\nread(), which is obviously broken, since the I/O layer may give you\nonly part of the input through such a read(). This made it basically\nimpossible to type the input in manually, for example.\n\nSigned-off-by: Petr Baudis <pasky@ucw.cz>\n\n---\ncommit f67b8ea0f157813d50371bed494452160c47744d\ntree e29e13f259279737dd62ca1b10ede1f8d5e2adb8\nparent bf36ee6ccc0dae5725edd7f5d56844a0eae158ad\nauthor Petr Baudis <pasky@ucw.cz> Sun, 29 May 2005 01:39:04 +0200\ncommitter Petr Baudis <xpasky@machine.sinus.cz> Sun, 29 May 2005 01:39:04 +0200\n\n mktag.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\nIndex: mktag.c\n===================================================================\n--- 01d01f6cebf110348cfa23c86d521118a00336ba/mktag.c  (mode:100644)\n+++ e29e13f259279737dd62ca1b10ede1f8d5e2adb8/mktag.c  (mode:100644)\n@@ -98,7 +98,7 @@\n \n int main(int argc, char **argv)\n {\n-\tunsigned long size;\n+\tunsigned long size, readsize;\n \tchar buffer[MAXSIZE];\n \tunsigned char result_sha1[20];\n \n@@ -106,7 +106,11 @@\n \t\tusage(\"cat <signaturefile> | git-mktag\");\n \n \t// Read the signature\n-\tsize = read(0, buffer, MAXSIZE);\n+\tsize = 0;\n+\tdo {\n+\t\treadsize = read(0, buffer + size, MAXSIZE - size);\n+\t\tsize += readsize;\n+\t} while (readsize);\n \n \t// Verify it for some basic sanity: it needs to start with \"object <sha1>\\ntype \"\n \tif (verify_tag(buffer, size) < 0)\n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}