git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@ucw.cz>
To: torvalds@osdl.org
Cc: git@vger.kernel.org
Subject: [GIT PATCH] Fix git-mktag to take the object input spliced arbitrarily
Date: Sun, 29 May 2005 20:52:30 +0200	[thread overview]
Message-ID: <20050529185230.GN1036@pasky.ji.cz> (raw)

Before, git-mktag would just try to get all the input through a single
read(), which is obviously broken, since the I/O layer may give you
only part of the input through such a read(). This made it basically
impossible to type the input in manually, for example.

Signed-off-by: Petr Baudis <pasky@ucw.cz>

---
commit f67b8ea0f157813d50371bed494452160c47744d
tree e29e13f259279737dd62ca1b10ede1f8d5e2adb8
parent bf36ee6ccc0dae5725edd7f5d56844a0eae158ad
author Petr Baudis <pasky@ucw.cz> Sun, 29 May 2005 01:39:04 +0200
committer Petr Baudis <xpasky@machine.sinus.cz> Sun, 29 May 2005 01:39:04 +0200

 mktag.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Index: mktag.c
===================================================================
--- 01d01f6cebf110348cfa23c86d521118a00336ba/mktag.c  (mode:100644)
+++ e29e13f259279737dd62ca1b10ede1f8d5e2adb8/mktag.c  (mode:100644)
@@ -98,7 +98,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned long size;
+	unsigned long size, readsize;
 	char buffer[MAXSIZE];
 	unsigned char result_sha1[20];
 
@@ -106,7 +106,11 @@
 		usage("cat <signaturefile> | git-mktag");
 
 	// Read the signature
-	size = read(0, buffer, MAXSIZE);
+	size = 0;
+	do {
+		readsize = read(0, buffer + size, MAXSIZE - size);
+		size += readsize;
+	} while (readsize);
 
 	// Verify it for some basic sanity: it needs to start with "object <sha1>\ntype "
 	if (verify_tag(buffer, size) < 0)


-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

                 reply	other threads:[~2005-05-29 18:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050529185230.GN1036@pasky.ji.cz \
    --to=pasky@ucw.cz \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).