summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c9af36)
raw | patch | inline | side by side (parent: 3c9af36)
author | Nicolas Pitre <nico@cam.org> | |
Thu, 26 Oct 2006 03:31:53 +0000 (23:31 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 27 Oct 2006 01:27:44 +0000 (18:27 -0700) |
It appears that git-unpack-objects writes the last part of the input
buffer to stdout after the pack has been parsed. This looks a bit
suspicious since the last fill() might have filled the buffer up to
the 4096 byte limit and more data might still be pending on stdin,
but since this is about being a drop-in replacement for unpack-objects
let's simply duplicate the same behavior for now.
[jc: with fix-up appeared in Nico's sleep]
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
buffer to stdout after the pack has been parsed. This looks a bit
suspicious since the last fill() might have filled the buffer up to
the 4096 byte limit and more data might still be pending on stdin,
but since this is about being a drop-in replacement for unpack-objects
let's simply duplicate the same behavior for now.
[jc: with fix-up appeared in Nico's sleep]
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
index-pack.c | patch | blob | history |
diff --git a/index-pack.c b/index-pack.c
index 2046b37e4bf8977c8b8e700dca4c8ce3c5ead327..5c747a62bae957cfbc3357361548412ac5929dd2 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
SHA1_Final(sha1, &input_ctx);
if (hashcmp(fill(20), sha1))
die("pack is corrupted (SHA1 mismatch)");
+ use(20);
/* If input_fd is a file, we should have reached its end now. */
if (fstat(input_fd, &st))
die("cannot fstat packfile: %s", strerror(errno));
- if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes + 20)
+ if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes)
die("pack has junk at the end");
if (!nr_deltas)
if (err)
die("error while closing pack file: %s", strerror(errno));
chmod(curr_pack_name, 0444);
+
+ /*
+ * Let's just mimic git-unpack-objects here and write
+ * the last part of the buffer to stdout.
+ */
+ while (input_len) {
+ err = xwrite(1, input_buffer + input_offset, input_len);
+ if (err <= 0)
+ break;
+ input_len -= err;
+ input_offset += err;
+ }
}
if (final_pack_name != curr_pack_name) {
nr_deltas - nr_resolved_deltas);
} else {
/* Flush remaining pack final 20-byte SHA1. */
- use(20);
flush();
}
free(deltas);
free(objects);
free(index_name_buf);
- printf("%s\n", sha1_to_hex(sha1));
+ if (!from_stdin)
+ printf("%s\n", sha1_to_hex(sha1));
return 0;
}