Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/ref-filter.c b/ref-filter.c
index e84efb53db..e2eac50d95 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -772,7 +772,8 @@ static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state
struct strbuf *unused_err)
{
struct ref_formatting_stack *new_stack;
- struct if_then_else *if_then_else = xcalloc(sizeof(struct if_then_else), 1);
+ struct if_then_else *if_then_else = xcalloc(1,
+ sizeof(struct if_then_else));
if_then_else->str = atomv->atom->u.if_then_else.str;
if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status;
@@ -1607,7 +1608,7 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
if (oi->info.contentp) {
*obj = parse_object_buffer(the_repository, &oi->oid, oi->type, oi->size, oi->content, &eaten);
- if (!obj) {
+ if (!*obj) {
if (!eaten)
free(oi->content);
return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
@@ -1676,7 +1677,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
int i;
struct object_info empty = OBJECT_INFO_INIT;
- ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
+ CALLOC_ARRAY(ref->value, used_atom_cnt);
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
@@ -2185,7 +2186,7 @@ static void reach_filter(struct ref_array *array,
if (!check_reachable)
return;
- to_clear = xcalloc(sizeof(struct commit *), array->nr);
+ CALLOC_ARRAY(to_clear, array->nr);
repo_init_revisions(the_repository, &revs, NULL);
@@ -2434,27 +2435,22 @@ int format_ref_array_item(struct ref_array_item *info,
return 0;
}
-void show_ref_array_item(struct ref_array_item *info,
- const struct ref_format *format)
-{
- struct strbuf final_buf = STRBUF_INIT;
- struct strbuf error_buf = STRBUF_INIT;
-
- if (format_ref_array_item(info, format, &final_buf, &error_buf))
- die("%s", error_buf.buf);
- fwrite(final_buf.buf, 1, final_buf.len, stdout);
- strbuf_release(&error_buf);
- strbuf_release(&final_buf);
- putchar('\n');
-}
-
void pretty_print_ref(const char *name, const struct object_id *oid,
const struct ref_format *format)
{
struct ref_array_item *ref_item;
+ struct strbuf output = STRBUF_INIT;
+ struct strbuf err = STRBUF_INIT;
+
ref_item = new_ref_array_item(name, oid);
ref_item->kind = ref_kind_from_refname(name);
- show_ref_array_item(ref_item, format);
+ if (format_ref_array_item(ref_item, format, &output, &err))
+ die("%s", err.buf);
+ fwrite(output.buf, 1, output.len, stdout);
+ putchar('\n');
+
+ strbuf_release(&err);
+ strbuf_release(&output);
free_array_item(ref_item);
}
@@ -2490,7 +2486,7 @@ void parse_ref_sorting(struct ref_sorting **sorting_tail, const char *arg)
{
struct ref_sorting *s;
- s = xcalloc(1, sizeof(*s));
+ CALLOC_ARRAY(s, 1);
s->next = *sorting_tail;
*sorting_tail = s;