From: Junio C Hamano Date: Tue, 18 Mar 2014 20:51:04 +0000 (-0700) Subject: Merge branch 'sh/use-hashcpy' X-Git-Tag: v2.0.0-rc0~90 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/006f678780e816a2540628e5473b0eea199d0b61?hp=-c Merge branch 'sh/use-hashcpy' * sh/use-hashcpy: Use hashcpy() when copying object names --- 006f678780e816a2540628e5473b0eea199d0b61 diff --combined bundle.c index 1388a3e6fd,7809fbb169..a85e0e4532 --- a/bundle.c +++ 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 2899729a8c,d490f7d7d8..0dd5084fe5 --- a/reflog-walk.c +++ b/reflog-walk.c @@@ -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 f89d589182,f90b7eafe4..28d5eca8ea --- a/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); }