{"thread":{"id":"7936","subject":"[PATCH 1/5] git-repack --max-pack-size: alter sha1close() 3rd argument","startedAt":"2007-05-02T00:03:58Z","lastAt":"2007-05-02T00:03:58Z","messageCount":1,"participants":["Dana How"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"40870","messageId":"4637D56E.8010009@gmail.com","threadId":"7936","inReplyTo":null,"subject":"[PATCH 1/5] git-repack --max-pack-size: alter sha1close() 3rd argument","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-05-02T00:03:58Z","receivedAt":"2007-05-02T00:03:58Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nupdate=0 suppressed writing the final SHA-1 but was not used.\nNow final=0 suppresses SHA-1 finalization, SHA-1 writing,\nand closing -- in other words,  only flush the buffer.\n\nSigned-off-by: Dana L. How <danahow@gmail.com>\n---\n csum-file.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/csum-file.c b/csum-file.c\nindex 7c806ad..9913cb5 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -29,18 +29,20 @@ static void sha1flush(struct sha1file *f, unsigned int count)\n \t}\n }\n \n-int sha1close(struct sha1file *f, unsigned char *result, int update)\n+int sha1close(struct sha1file *f, unsigned char *result, int final)\n {\n \tunsigned offset = f->offset;\n \tif (offset) {\n \t\tSHA1_Update(&f->ctx, f->buffer, offset);\n \t\tsha1flush(f, offset);\n+\t\tf->offset = 0;\n \t}\n+\tif (!final)\n+\t\treturn 0;\t/* only want to flush (no checksum write, no close) */\n \tSHA1_Final(f->buffer, &f->ctx);\n \tif (result)\n \t\thashcpy(result, f->buffer);\n-\tif (update)\n-\t\tsha1flush(f, 20);\n+\tsha1flush(f, 20);\n \tif (close(f->fd))\n \t\tdie(\"%s: sha1 file error on close (%s)\", f->name, strerror(errno));\n \tfree(f);\n-- \n1.5.2.rc0.789.gd951\n"}]}