diff options
| author | Junio C Hamano <gitster@pobox.com> | 2009-06-18 10:33:09 -0700 | 
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2009-06-18 10:33:09 -0700 | 
| commit | 3b91202150fef842f210668cd84fd52142dffd5c (patch) | |
| tree | 0f4061ceb5bfdf80ca26f1efe5e3b69b3fc2655e /builtin-for-each-ref.c | |
| parent | 907ffe1522560ba71991ae4d2b03e357a8f57110 (diff) | |
| parent | b7dd2d20fad1036ce7da0b635a8bb14cd4230f1a (diff) | |
| download | git-3b91202150fef842f210668cd84fd52142dffd5c.tar.gz | |
Merge branch 'ak/maint-for-each-ref-no-lookup'
* ak/maint-for-each-ref-no-lookup:
  for-each-ref: Do not lookup objects when they will not be used
Diffstat (limited to 'builtin-for-each-ref.c')
| -rw-r--r-- | builtin-for-each-ref.c | 26 | 
1 files changed, 17 insertions, 9 deletions
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 784733b25d..d7cc8cafbf 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -561,14 +561,6 @@ static void populate_value(struct refinfo *ref)  	ref->value = xcalloc(sizeof(struct atom_value), used_atom_cnt); -	buf = get_obj(ref->objectname, &obj, &size, &eaten); -	if (!buf) -		die("missing object %s for %s", -		    sha1_to_hex(ref->objectname), ref->refname); -	if (!obj) -		die("parse_object_buffer failed on %s for %s", -		    sha1_to_hex(ref->objectname), ref->refname); -  	/* Fill in specials first */  	for (i = 0; i < used_atom_cnt; i++) {  		const char *name = used_atom[i]; @@ -621,6 +613,22 @@ static void populate_value(struct refinfo *ref)  		}  	} +	for (i = 0; i < used_atom_cnt; i++) { +		struct atom_value *v = &ref->value[i]; +		if (v->s == NULL) +			goto need_obj; +	} +	return; + + need_obj: +	buf = get_obj(ref->objectname, &obj, &size, &eaten); +	if (!buf) +		die("missing object %s for %s", +		    sha1_to_hex(ref->objectname), ref->refname); +	if (!obj) +		die("parse_object_buffer failed on %s for %s", +		    sha1_to_hex(ref->objectname), ref->refname); +  	grab_values(ref->value, 0, obj, buf, size);  	if (!eaten)  		free(buf); @@ -926,7 +934,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)  	memset(&cbdata, 0, sizeof(cbdata));  	cbdata.grab_pattern = argv; -	for_each_ref(grab_single_ref, &cbdata); +	for_each_rawref(grab_single_ref, &cbdata);  	refs = cbdata.grab_array;  	num_refs = cbdata.grab_cnt;  | 
