Merge branch 'maint'
[gitweb.git] / fast-import.c
index 6c43a0d37f781294a8844ea52c9ce9728396f456..b4cbcd90118c47d47e8940322c8ec2161b33a92a 100644 (file)
@@ -673,7 +673,7 @@ static void fixup_header_footer(void)
 
        buf = xmalloc(buf_sz);
        for (;;) {
-               size_t n = xread(pack_fd, buf, buf_sz);
+               ssize_t n = xread(pack_fd, buf, buf_sz);
                if (!n)
                        break;
                if (n < 0)
@@ -904,6 +904,12 @@ static int store_object(
        if (e->offset) {
                duplicate_count_by_type[type]++;
                return 1;
+       } else if (find_sha1_pack(sha1, packed_git)) {
+               e->type = type;
+               e->pack_id = MAX_PACK_ID;
+               e->offset = 1; /* just not zero! */
+               duplicate_count_by_type[type]++;
+               return 1;
        }
 
        if (last && last->data && last->depth < max_depth) {
@@ -2023,6 +2029,7 @@ static void import_marks(const char *input_file)
                        e = insert_object(sha1);
                        e->type = type;
                        e->pack_id = MAX_PACK_ID;
+                       e->offset = 1; /* just not zero! */
                }
                insert_mark(mark, e);
        }
@@ -2088,6 +2095,7 @@ int main(int argc, const char **argv)
        if (i != argc)
                usage(fast_import_usage);
 
+       prepare_packed_git();
        start_packfile();
        for (;;) {
                read_next_command();