Merge branch 'bc/object-id'
Conversion from uchar[20] to struct object_id continues. * bc/object-id: (53 commits) object: convert parse_object* to take struct object_id tree: convert parse_tree_indirect to struct object_id sequencer: convert do_recursive_merge to struct object_id diff-lib: convert do_diff_cache to struct object_id builtin/ls-tree: convert to struct object_id merge: convert checkout_fast_forward to struct object_id sequencer: convert fast_forward_to to struct object_id builtin/ls-files: convert overlay_tree_on_cache to object_id builtin/read-tree: convert to struct object_id sha1_name: convert internals of peel_onion to object_id upload-pack: convert remaining parse_object callers to object_id revision: convert remaining parse_object callers to object_id revision: rename add_pending_sha1 to add_pending_oid http-push: convert process_ls_object and descendants to object_id refs/files-backend: convert many internals to struct object_id refs: convert struct ref_update to use struct object_id ref-filter: convert some static functions to struct object_id Convert struct ref_array_item to struct object_id Convert the verify_pack callback to struct object_id Convert lookup_tag to struct object_id ...
This commit is contained in:
38
ref-filter.c
38
ref-filter.c
@ -677,13 +677,13 @@ int verify_ref_format(const char *format)
|
||||
* by the "struct object" representation, set *eaten as well---it is a
|
||||
* signal from parse_object_buffer to us not to free the buffer.
|
||||
*/
|
||||
static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)
|
||||
static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
|
||||
{
|
||||
enum object_type type;
|
||||
void *buf = read_sha1_file(sha1, &type, sz);
|
||||
void *buf = read_sha1_file(oid->hash, &type, sz);
|
||||
|
||||
if (buf)
|
||||
*obj = parse_object_buffer(sha1, type, *sz, buf, eaten);
|
||||
*obj = parse_object_buffer(oid, type, *sz, buf, eaten);
|
||||
else
|
||||
*obj = NULL;
|
||||
return buf;
|
||||
@ -1293,7 +1293,7 @@ static void populate_value(struct ref_array_item *ref)
|
||||
struct object *obj;
|
||||
int eaten, i;
|
||||
unsigned long size;
|
||||
const unsigned char *tagged;
|
||||
const struct object_id *tagged;
|
||||
|
||||
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
|
||||
|
||||
@ -1366,14 +1366,14 @@ static void populate_value(struct ref_array_item *ref)
|
||||
v->s = xstrdup(buf + 1);
|
||||
}
|
||||
continue;
|
||||
} else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
|
||||
} else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
|
||||
continue;
|
||||
} else if (!strcmp(name, "HEAD")) {
|
||||
const char *head;
|
||||
unsigned char sha1[20];
|
||||
struct object_id oid;
|
||||
|
||||
head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
|
||||
sha1, NULL);
|
||||
oid.hash, NULL);
|
||||
if (head && !strcmp(ref->refname, head))
|
||||
v->s = "*";
|
||||
else
|
||||
@ -1415,13 +1415,13 @@ static void populate_value(struct ref_array_item *ref)
|
||||
return;
|
||||
|
||||
need_obj:
|
||||
buf = get_obj(ref->objectname, &obj, &size, &eaten);
|
||||
buf = get_obj(&ref->objectname, &obj, &size, &eaten);
|
||||
if (!buf)
|
||||
die(_("missing object %s for %s"),
|
||||
sha1_to_hex(ref->objectname), ref->refname);
|
||||
oid_to_hex(&ref->objectname), ref->refname);
|
||||
if (!obj)
|
||||
die(_("parse_object_buffer failed on %s for %s"),
|
||||
sha1_to_hex(ref->objectname), ref->refname);
|
||||
oid_to_hex(&ref->objectname), ref->refname);
|
||||
|
||||
grab_values(ref->value, 0, obj, buf, size);
|
||||
if (!eaten)
|
||||
@ -1438,7 +1438,7 @@ static void populate_value(struct ref_array_item *ref)
|
||||
* If it is a tag object, see if we use a value that derefs
|
||||
* the object, and if we do grab the object it refers to.
|
||||
*/
|
||||
tagged = ((struct tag *)obj)->tagged->oid.hash;
|
||||
tagged = &((struct tag *)obj)->tagged->oid;
|
||||
|
||||
/*
|
||||
* NEEDSWORK: This derefs tag only once, which
|
||||
@ -1449,10 +1449,10 @@ static void populate_value(struct ref_array_item *ref)
|
||||
buf = get_obj(tagged, &obj, &size, &eaten);
|
||||
if (!buf)
|
||||
die(_("missing object %s for %s"),
|
||||
sha1_to_hex(tagged), ref->refname);
|
||||
oid_to_hex(tagged), ref->refname);
|
||||
if (!obj)
|
||||
die(_("parse_object_buffer failed on %s for %s"),
|
||||
sha1_to_hex(tagged), ref->refname);
|
||||
oid_to_hex(tagged), ref->refname);
|
||||
grab_values(ref->value, 1, obj, buf, size);
|
||||
if (!eaten)
|
||||
free(buf);
|
||||
@ -1687,7 +1687,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
|
||||
|
||||
if (oid_array_lookup(points_at, oid) >= 0)
|
||||
return oid;
|
||||
obj = parse_object(oid->hash);
|
||||
obj = parse_object(oid);
|
||||
if (!obj)
|
||||
die(_("malformed object at '%s'"), refname);
|
||||
if (obj->type == OBJ_TAG)
|
||||
@ -1704,7 +1704,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
|
||||
{
|
||||
struct ref_array_item *ref;
|
||||
FLEX_ALLOC_STR(ref, refname, refname);
|
||||
hashcpy(ref->objectname, objectname);
|
||||
hashcpy(ref->objectname.hash, objectname);
|
||||
ref->flag = flag;
|
||||
|
||||
return ref;
|
||||
@ -1782,7 +1782,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
|
||||
* non-commits early. The actual filtering is done later.
|
||||
*/
|
||||
if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {
|
||||
commit = lookup_commit_reference_gently(oid->hash, 1);
|
||||
commit = lookup_commit_reference_gently(oid, 1);
|
||||
if (!commit)
|
||||
return 0;
|
||||
/* We perform the filtering for the '--contains' option... */
|
||||
@ -2090,7 +2090,7 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
|
||||
int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
|
||||
{
|
||||
struct ref_filter *rf = opt->value;
|
||||
unsigned char sha1[20];
|
||||
struct object_id oid;
|
||||
int no_merged = starts_with(opt->long_name, "no");
|
||||
|
||||
if (rf->merge) {
|
||||
@ -2105,10 +2105,10 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
|
||||
? REF_FILTER_MERGED_OMIT
|
||||
: REF_FILTER_MERGED_INCLUDE;
|
||||
|
||||
if (get_sha1(arg, sha1))
|
||||
if (get_oid(arg, &oid))
|
||||
die(_("malformed object name %s"), arg);
|
||||
|
||||
rf->merge_commit = lookup_commit_reference_gently(sha1, 0);
|
||||
rf->merge_commit = lookup_commit_reference_gently(&oid, 0);
|
||||
if (!rf->merge_commit)
|
||||
return opterror(opt, "must point to a commit", 0);
|
||||
|
||||
|
Reference in New Issue
Block a user