Merge branch 'sh/use-hashcpy'
authorJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2014 20:51:04 +0000 (13:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2014 20:51:05 +0000 (13:51 -0700)
* sh/use-hashcpy:
Use hashcpy() when copying object names

1  2 
bundle.c
reflog-walk.c
refs.c
diff --combined bundle.c
index 1388a3e6fdf352fe670e4236f305c1b1e97b74f2,7809fbb1698851fa929a288fd46d3b437e5113ac..a85e0e4532ad10934b3d9c510db9e26b338f14f1
+++ b/bundle.c
@@@ -14,8 -14,12 +14,8 @@@ static const char bundle_signature[] = 
  static void add_to_ref_list(const unsigned char *sha1, const char *name,
                struct ref_list *list)
  {
 -      if (list->nr + 1 >= list->alloc) {
 -              list->alloc = alloc_nr(list->nr + 1);
 -              list->list = xrealloc(list->list,
 -                              list->alloc * sizeof(list->list[0]));
 -      }
 +      ALLOC_GROW(list->list, list->nr + 1, list->alloc);
-       memcpy(list->list[list->nr].sha1, sha1, 20);
+       hashcpy(list->list[list->nr].sha1, sha1);
        list->list[list->nr].name = xstrdup(name);
        list->nr++;
  }
diff --combined reflog-walk.c
index 2899729a8cbec4766182a1562c0c96d643de3a71,d490f7d7d80f19c63276bdd1f402ae55ea59f03c..0dd5084fe5c80fe9504cfe4ec4bff3722b733eaf
@@@ -26,10 -26,14 +26,10 @@@ static int read_one_reflog(unsigned cha
        struct complete_reflogs *array = cb_data;
        struct reflog_info *item;
  
 -      if (array->nr >= array->alloc) {
 -              array->alloc = alloc_nr(array->nr + 1);
 -              array->items = xrealloc(array->items, array->alloc *
 -                      sizeof(struct reflog_info));
 -      }
 +      ALLOC_GROW(array->items, array->nr + 1, array->alloc);
        item = array->items + array->nr;
-       memcpy(item->osha1, osha1, 20);
-       memcpy(item->nsha1, nsha1, 20);
+       hashcpy(item->osha1, osha1);
+       hashcpy(item->nsha1, nsha1);
        item->email = xstrdup(email);
        item->timestamp = timestamp;
        item->tz = tz;
@@@ -110,7 -114,11 +110,7 @@@ static void add_commit_info(struct comm
                struct commit_info_lifo *lifo)
  {
        struct commit_info *info;
 -      if (lifo->nr >= lifo->alloc) {
 -              lifo->alloc = alloc_nr(lifo->nr + 1);
 -              lifo->items = xrealloc(lifo->items,
 -                      lifo->alloc * sizeof(struct commit_info));
 -      }
 +      ALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);
        info = lifo->items + lifo->nr;
        info->commit = commit;
        info->util = util;
diff --combined refs.c
index f89d589182fcfc595ff1d60f01ffe25e1ea81579,f90b7eafe4f7c58502e8ad18f67cbc84c4367fe4..28d5eca8eaff7be48a4b89e6217886b8c96eb3b2
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -1222,7 -1222,7 +1222,7 @@@ static int resolve_gitlink_packed_ref(s
        if (ref == NULL)
                return -1;
  
-       memcpy(sha1, ref->u.value.sha1, 20);
+       hashcpy(sha1, ref->u.value.sha1);
        return 0;
  }
  
@@@ -1477,7 -1477,7 +1477,7 @@@ static int filter_refs(const char *refn
                       void *data)
  {
        struct ref_filter *filter = (struct ref_filter *)data;
 -      if (fnmatch(filter->pattern, refname, 0))
 +      if (wildmatch(filter->pattern, refname, 0, NULL))
                return 0;
        return filter->fn(refname, sha1, flags, filter->cb_data);
  }