{"thread":{"id":"7915","subject":"[PATCH 3/8] git-repack --max-pack-size: make close optional in sha1close()","startedAt":"2007-04-30T23:20:14Z","lastAt":"2007-05-01T05:24:52Z","messageCount":3,"participants":["Dana How","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"40770","messageId":"463679AE.7020106@gmail.com","threadId":"7915","inReplyTo":null,"subject":"[PATCH 3/8] git-repack --max-pack-size: make close optional in sha1close()","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-30T23:20:14Z","receivedAt":"2007-04-30T23:20:14Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nsha1close() flushes, writes checksum, and closes.\nThe 2nd can be suppressed; make the last suppressible as well.\n\nSigned-off-by: Dana L. How <danahow@gmail.com>\n---\n csum-file.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/csum-file.c b/csum-file.c\nindex 7c806ad..993c899 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -35,7 +35,10 @@ int sha1close(struct sha1file *f, unsigned char *result, int update)\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 (update < 0)\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-- \n1.5.2.rc0.766.gba60-dirty\n"},{"id":"40788","messageId":"20070501050155.GY5942@spearce.org","threadId":"7915","inReplyTo":"463679AE.7020106@gmail.com","subject":"Re: [PATCH 3/8] git-repack --max-pack-size: make close optional in sha1close()","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-01T05:01:56Z","receivedAt":"2007-05-01T05:01:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Dana How <danahow@gmail.com> wrote:\n> sha1close() flushes, writes checksum, and closes.\n> The 2nd can be suppressed; make the last suppressible as well.\n...\n> diff --git a/csum-file.c b/csum-file.c\n> index 7c806ad..993c899 100644\n> --- a/csum-file.c\n> +++ b/csum-file.c\n> @@ -35,7 +35,10 @@ int sha1close(struct sha1file *f, unsigned char *result, int update)\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 (update < 0)\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\nHuh.  Nobody currently uses that update parameter; all current in-tree\ncallers (which better be *all* callers since we don't have a true\nlibgit!) seem to always pass a 1 for this argument.  This makes the\nlater:\n\n  if (update)\n    sha1flush(f, 20);\n\nalways true anytime sha1close is called.  Maybe we should be\nredefining that update argument to be 1 means do all work, 0 means\nreturn where you return update < 0 above?\n\n-- \nShawn.\n"},{"id":"40790","messageId":"56b7f5510704302224r637788fela543df5eaad2317d@mail.gmail.com","threadId":"7915","inReplyTo":"20070501050155.GY5942@spearce.org","subject":"Re: [PATCH 3/8] git-repack --max-pack-size: make close optional in sha1close()","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-05-01T05:24:52Z","receivedAt":"2007-05-01T05:24:52Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"On 4/30/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Dana How <danahow@gmail.com> wrote:\n> > sha1close() flushes, writes checksum, and closes.\n> > The 2nd can be suppressed; make the last suppressible as well.\n> ...\n> > diff --git a/csum-file.c b/csum-file.c\n> > --- a/csum-file.c\n> > +++ b/csum-file.c\n> > @@ -35,7 +35,10 @@ int sha1close(struct sha1file *f, unsigned char *result, int update)\n> > +             f->offset = 0;\n> >       }\n> > +     if (update < 0)\n> > +             return 0;       /* only want to flush (no checksum write, no close) */\n>\n> Huh.  Nobody currently uses that update parameter; all current in-tree\n> callers (which better be *all* callers since we don't have a true\n> libgit!) seem to always pass a 1 for this argument.  This makes the\n> later:\n>\n>   if (update)\n>     sha1flush(f, 20);\n>\n> always true anytime sha1close is called.  Maybe we should be\n> redefining that update argument to be 1 means do all work, 0 means\n> return where you return update < 0 above?\n\nConsidering I had to look at all the sha1close call sites\nto confirm -1 was a safe new value,\nI should have reached your conclusion as well.\nBut I was really trying to focus on additions, not alterations.\n\nI'll either roll this into my next patchset (also in pack-objects),\nor include it in any other changes to this patchset if any.\n\nThanks,\n-- \nDana L. How  danahow@gmail.com  +1 650 804 5991 cell\n"}]}