Replace use_packed_git with window cursors.
[gitweb.git] / builtin-pack-objects.c
index a2dc7d1d9d39436e8e5266d1d4bb693b06a54b17..6d7ae7f1aef758cbcd2bbb931287826fc8267dd8 100644 (file)
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
-#include <sys/time.h>
-#include <signal.h>
 
 static const char pack_usage[] = "\
 git-pack-objects [{ -q | --progress | --all-progress }] \n\
        [--local] [--incremental] [--window=N] [--depth=N] \n\
        [--no-reuse-delta] [--delta-base-offset] [--non-empty] \n\
-       [--revs [--unpacked | --all]*] [--stdout | base-name] \n\
+       [--revs [--unpacked | --all]*] [--reflog] [--stdout | base-name] \n\
        [<ref-list | <object-list]";
 
 struct object_entry {
@@ -418,6 +416,7 @@ static unsigned long write_object(struct sha1file *f,
        }
        else {
                struct packed_git *p = entry->in_pack;
+               struct pack_window *w_curs = NULL;
 
                if (entry->delta) {
                        obj_type = (allow_ofs_delta && entry->delta->offset) ?
@@ -439,16 +438,14 @@ static unsigned long write_object(struct sha1file *f,
                        hdrlen += 20;
                }
 
-               use_packed_git(p);
-               buf = (char *) p->pack_base
-                       + entry->in_pack_offset
-                       + entry->in_pack_header_size;
+               buf = use_pack(p, &w_curs, entry->in_pack_offset
+                       + entry->in_pack_header_size, NULL);
                datalen = find_packed_object_size(p, entry->in_pack_offset)
                                - entry->in_pack_header_size;
                if (!pack_to_stdout && check_inflate(buf, datalen, entry->size))
                        die("corrupt delta in pack %s", sha1_to_hex(entry->sha1));
                sha1write(f, buf, datalen);
-               unuse_packed_git(p);
+               unuse_pack(&w_curs);
                reused++;
        }
        if (entry->delta)
@@ -939,14 +936,13 @@ static void check_object(struct object_entry *entry)
 
        if (entry->in_pack && !entry->preferred_base) {
                struct packed_git *p = entry->in_pack;
+               struct pack_window *w_curs = NULL;
                unsigned long left = p->pack_size - entry->in_pack_offset;
                unsigned long size, used;
                unsigned char *buf;
                struct object_entry *base_entry = NULL;
 
-               use_packed_git(p);
-               buf = p->pack_base;
-               buf += entry->in_pack_offset;
+               buf = use_pack(p, &w_curs, entry->in_pack_offset, NULL);
 
                /* We want in_pack_type even if we do not reuse delta.
                 * There is no point not reusing non-delta representations.
@@ -992,7 +988,7 @@ static void check_object(struct object_entry *entry)
                        if (base_name)
                                base_entry = locate_object_entry(base_name);
                }
-               unuse_packed_git(p);
+               unuse_pack(&w_curs);
                entry->in_pack_header_size = used;
 
                if (base_entry) {
@@ -1577,6 +1573,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                }
                if (!strcmp("--unpacked", arg) ||
                    !strncmp("--unpacked=", arg, 11) ||
+                   !strcmp("--reflog", arg) ||
                    !strcmp("--all", arg)) {
                        use_internal_rev_list = 1;
                        if (ARRAY_SIZE(rp_av) - 1 <= rp_ac)