Merge branch 'rs/copy-array'
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Jul 2019 22:25:38 +0000 (15:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Jul 2019 22:25:38 +0000 (15:25 -0700)
Code clean-up.

* rs/copy-array:
use COPY_ARRAY for copying arrays
coccinelle: use COPY_ARRAY for copying arrays

1  2 
fast-import.c
packfile.c
diff --combined fast-import.c
index 76a7bd369987f7fed63c0f602efe59e0edbd01b8,606d44278d88b3ae23dac934dc1e77eb0b138c31..6dfdd6801c720f3b693ca6b09f8b7b3cf0f0c764
@@@ -644,7 -644,7 +644,7 @@@ static struct tree_content *grow_tree_c
        struct tree_content *r = new_tree_content(t->entry_count + amt);
        r->entry_count = t->entry_count;
        r->delta_depth = t->delta_depth;
-       memcpy(r->entries,t->entries,t->entry_count*sizeof(t->entries[0]));
+       COPY_ARRAY(r->entries, t->entries, t->entry_count);
        release_tree_content(t);
        return r;
  }
@@@ -2585,7 -2585,6 +2585,7 @@@ static void parse_new_commit(const cha
        struct branch *b;
        char *author = NULL;
        char *committer = NULL;
 +      const char *encoding = NULL;
        struct hash_list *merge_list = NULL;
        unsigned int merge_count;
        unsigned char prev_fanout, new_fanout;
        }
        if (!committer)
                die("Expected committer but didn't get one");
 +      if (skip_prefix(command_buf.buf, "encoding ", &encoding))
 +              read_next_command();
        parse_data(&msg, 0, NULL);
        read_next_command();
        parse_from(b);
        }
        strbuf_addf(&new_data,
                "author %s\n"
 -              "committer %s\n"
 -              "\n",
 +              "committer %s\n",
                author ? author : committer, committer);
 +      if (encoding)
 +              strbuf_addf(&new_data,
 +                      "encoding %s\n",
 +                      encoding);
 +      strbuf_addch(&new_data, '\n');
        strbuf_addbuf(&new_data, &msg);
        free(author);
        free(committer);
diff --combined packfile.c
index ed611875045ebf5d682d33d27a124cb04958673a,2ff570fbfdb2fc0e7f2cbc7bb8d1f25cb7b402bd..c0d83fdfed973de8574224e46fb0afd4be0a98c9
@@@ -16,7 -16,6 +16,7 @@@
  #include "tree.h"
  #include "object-store.h"
  #include "midx.h"
 +#include "commit-graph.h"
  
  char *odb_pack_name(struct strbuf *buf,
                    const unsigned char *sha1,
@@@ -337,7 -336,7 +337,7 @@@ void close_pack(struct packed_git *p
        close_pack_index(p);
  }
  
 -void close_all_packs(struct raw_object_store *o)
 +void close_object_store(struct raw_object_store *o)
  {
        struct packed_git *p;
  
                close_midx(o->multi_pack_index);
                o->multi_pack_index = NULL;
        }
 +
 +      close_commit_graph(o);
  }
  
  /*
@@@ -643,7 -640,7 +643,7 @@@ unsigned char *use_pack(struct packed_g
                        while (packed_git_limit < pack_mapped
                                && unuse_one_window(p))
                                ; /* nothing */
 -                      win->base = xmmap(NULL, win->len,
 +                      win->base = xmmap_gently(NULL, win->len,
                                PROT_READ, MAP_PRIVATE,
                                p->pack_fd, win->offset);
                        if (win->base == MAP_FAILED)
@@@ -1272,7 -1269,7 +1272,7 @@@ static enum object_type packed_to_objec
                if (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {
                        poi_stack_alloc = alloc_nr(poi_stack_nr);
                        ALLOC_ARRAY(poi_stack, poi_stack_alloc);
-                       memcpy(poi_stack, small_poi_stack, sizeof(off_t)*poi_stack_nr);
+                       COPY_ARRAY(poi_stack, small_poi_stack, poi_stack_nr);
                } else {
                        ALLOC_GROW(poi_stack, poi_stack_nr+1, poi_stack_alloc);
                }
@@@ -1682,8 -1679,8 +1682,8 @@@ void *unpack_entry(struct repository *r
                    && delta_stack == small_delta_stack) {
                        delta_stack_alloc = alloc_nr(delta_stack_nr);
                        ALLOC_ARRAY(delta_stack, delta_stack_alloc);
-                       memcpy(delta_stack, small_delta_stack,
-                              sizeof(*delta_stack)*delta_stack_nr);
+                       COPY_ARRAY(delta_stack, small_delta_stack,
+                                  delta_stack_nr);
                } else {
                        ALLOC_GROW(delta_stack, delta_stack_nr+1, delta_stack_alloc);
                }