Re: [PATCH 1/2] sha1_file: freshen pack objects before loose
- From
- Stefan Saasen <ssaasen@atlassian.com>
- Date
- Apr 21, 2015, 00:46 UTC
- Message-ID
- <CADoxLGPNEjDWBjsYn30acapCUj6TfMw5z34W6f_9OjhXySFMLQ@mail.gmail.com>
- In-Reply-To
- <20150420195403.GA15760@peff.net>
I didn't expect anything else (as the patch is the same as the previous one) but I verified that applying this patch has the desired effect (https://bitbucket.org/snippets/ssaasen/9AXg).
Thanks for the fix Jeff.
On 21 April 2015 at 05:54, Jeff King <peff@peff.net> wrote:
Show 34 quoted lines
> When writing out an object file, we first check whether it > already exists and if so optimize out the write. Prior to > 33d4221, we did this by calling has_sha1_file(), which will > check for packed objects followed by loose. Since that > commit, we check loose objects first. > > For the common case of a repository whose objects are mostly > packed, this means we will make a lot of extra access() > system calls checking for loose objects. We should follow > the same packed-then-loose order that all of our other > lookups use. > > Reported-by: Stefan Saasen <ssaasen@atlassian.com> > Signed-off-by: Jeff King <peff@peff.net> > --- > sha1_file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sha1_file.c b/sha1_file.c > index 88f06ba..822aaef 100644 > --- a/sha1_file.c > +++ b/sha1_file.c > @@ -3014,7 +3014,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign > write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen); > if (returnsha1) > hashcpy(returnsha1, sha1); > - if (freshen_loose_object(sha1) || freshen_packed_object(sha1)) > + if (freshen_packed_object(sha1) || freshen_loose_object(sha1)) > return 0; > return write_loose_object(sha1, hdr, hdrlen, buf, len, 0); > } > -- > 2.4.0.rc2.384.g7297a4a >