]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-pack-objects.c
Git.pm: Make _temp_cache use the repository directory
[git.git] / builtin-pack-objects.c
index 15b80db5a1a43ae2ae44375c2cb27978c2e70a71..95e6faf1e6228dcee2fed692c9273e1fccbcef16 100644 (file)
@@ -245,8 +245,16 @@ static unsigned long write_object(struct sha1file *f,
        type = entry->type;
 
        /* write limit if limited packsize and not first object */
-       limit = pack_size_limit && nr_written ?
-                       pack_size_limit - write_offset : 0;
+       if (!pack_size_limit || !nr_written)
+               limit = 0;
+       else if (pack_size_limit <= write_offset)
+               /*
+                * the earlier object did not fit the limit; avoid
+                * mistaking this with unlimited (i.e. limit = 0).
+                */
+               limit = 1;
+       else
+               limit = pack_size_limit - write_offset;
 
        if (!entry->delta)
                usable_delta = 0;       /* no delta */