Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert struct object to object_id
struct object is one of the major data structures dealing with object
IDs.  Convert it to use struct object_id instead of an unsigned char
array.  Convert get_object_hash to refer to the new member as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
brian m. carlson authored and Jeff King committed Nov 20, 2015
1 parent 7999b2c commit f2fd076
Show file tree
Hide file tree
Showing 54 changed files with 256 additions and 256 deletions.
4 changes: 2 additions & 2 deletions bisect.c
Expand Up @@ -193,7 +193,7 @@ static int compare_commit_dist(const void *a_, const void *b_)
b = (struct commit_dist *)b_;
if (a->distance != b->distance)
return b->distance - a->distance; /* desc sort */
return hashcmp(a->commit->object.sha1, b->commit->object.sha1);
return oidcmp(&a->commit->object.oid, &b->commit->object.oid);
}

static struct commit_list *best_bisection_sorted(struct commit_list *list, int nr)
Expand Down Expand Up @@ -575,7 +575,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)

for (i = 0; cur; cur = cur->next, i++) {
if (i == index) {
if (hashcmp(cur->item->object.sha1, current_bad_oid->hash))
if (oidcmp(&cur->item->object.oid, current_bad_oid))
return cur;
if (previous)
return previous;
Expand Down
2 changes: 1 addition & 1 deletion builtin/am.c
Expand Up @@ -1441,7 +1441,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
assert(!state->msg);
msg = strstr(buffer, "\n\n");
if (!msg)
die(_("unable to parse commit %s"), sha1_to_hex(commit->object.sha1));
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
state->msg = xstrdup(msg + 2);
state->msg_len = strlen(state->msg);
}
Expand Down
32 changes: 16 additions & 16 deletions builtin/blame.c
Expand Up @@ -557,7 +557,7 @@ static struct origin *find_origin(struct scoreboard *sb,
PATHSPEC_LITERAL_PATH, "", paths);
diff_setup_done(&diff_opts);

if (is_null_sha1(origin->commit->object.sha1))
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
Expand Down Expand Up @@ -627,7 +627,7 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_opts.single_follow = origin->path;
diff_setup_done(&diff_opts);

if (is_null_sha1(origin->commit->object.sha1))
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
Expand Down Expand Up @@ -977,8 +977,8 @@ static void pass_blame_to_parent(struct scoreboard *sb,

if (diff_hunks(&file_p, &file_o, 0, blame_chunk_cb, &d))
die("unable to generate diff (%s -> %s)",
sha1_to_hex(parent->commit->object.sha1),
sha1_to_hex(target->commit->object.sha1));
oid_to_hex(&parent->commit->object.oid),
oid_to_hex(&target->commit->object.oid));
/* The rest are the same as the parent */
blame_chunk(&d.dstq, &d.srcq, INT_MAX, d.offset, INT_MAX, parent);
*d.dstq = NULL;
Expand Down Expand Up @@ -1126,7 +1126,7 @@ static void find_copy_in_blob(struct scoreboard *sb,
memset(split, 0, sizeof(struct blame_entry [3]));
if (diff_hunks(file_p, &file_o, 1, handle_split_cb, &d))
die("unable to generate diff (%s)",
sha1_to_hex(parent->commit->object.sha1));
oid_to_hex(&parent->commit->object.oid));
/* remainder, if any, all match the preimage */
handle_split(sb, ent, d.tlno, d.plno, ent->num_lines, parent, split);
}
Expand Down Expand Up @@ -1275,7 +1275,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
&& (!porigin || strcmp(target->path, porigin->path))))
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);

if (is_null_sha1(target->commit->object.sha1))
if (is_null_oid(&target->commit->object.oid))
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
Expand Down Expand Up @@ -1690,7 +1690,7 @@ static void get_commit_info(struct commit *commit,
if (len)
strbuf_add(&ret->summary, subject, len);
else
strbuf_addf(&ret->summary, "(%s)", sha1_to_hex(commit->object.sha1));
strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));

unuse_commit_buffer(commit, message);
}
Expand Down Expand Up @@ -1733,7 +1733,7 @@ static int emit_one_suspect_detail(struct origin *suspect, int repeat)
printf("boundary\n");
if (suspect->previous) {
struct origin *prev = suspect->previous;
printf("previous %s ", sha1_to_hex(prev->commit->object.sha1));
printf("previous %s ", oid_to_hex(&prev->commit->object.oid));
write_name_quoted(prev->path, stdout, '\n');
}

Expand All @@ -1752,7 +1752,7 @@ static void found_guilty_entry(struct blame_entry *ent)
struct origin *suspect = ent->suspect;

printf("%s %d %d %d\n",
sha1_to_hex(suspect->commit->object.sha1),
oid_to_hex(&suspect->commit->object.oid),
ent->s_lno + 1, ent->lno + 1, ent->num_lines);
emit_one_suspect_detail(suspect, 0);
write_filename_info(suspect->path);
Expand Down Expand Up @@ -1882,7 +1882,7 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent,
struct origin *suspect = ent->suspect;
char hex[GIT_SHA1_HEXSZ + 1];

sha1_to_hex_r(hex, suspect->commit->object.sha1);
sha1_to_hex_r(hex, suspect->commit->object.oid.hash);
printf("%s %d %d %d\n",
hex,
ent->s_lno + 1,
Expand Down Expand Up @@ -1922,7 +1922,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);

get_commit_info(suspect->commit, &ci, 1);
sha1_to_hex_r(hex, suspect->commit->object.sha1);
sha1_to_hex_r(hex, suspect->commit->object.oid.hash);

cp = nth_line(sb, ent->lno);
for (cnt = 0; cnt < ent->num_lines; cnt++) {
Expand Down Expand Up @@ -2153,7 +2153,7 @@ static void sanity_check_refcnt(struct scoreboard *sb)
if (ent->suspect->refcnt <= 0) {
fprintf(stderr, "%s in %s has negative refcnt %d\n",
ent->suspect->path,
sha1_to_hex(ent->suspect->commit->object.sha1),
oid_to_hex(&ent->suspect->commit->object.oid),
ent->suspect->refcnt);
baa = 1;
}
Expand Down Expand Up @@ -2310,7 +2310,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
strbuf_addstr(&msg, "tree 0000000000000000000000000000000000000000\n");
for (parent = commit->parents; parent; parent = parent->next)
strbuf_addf(&msg, "parent %s\n",
sha1_to_hex(parent->item->object.sha1));
oid_to_hex(&parent->item->object.oid));
strbuf_addf(&msg,
"author %s\n"
"committer %s\n\n"
Expand Down Expand Up @@ -2740,7 +2740,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)

sb.revs->children.name = "children";
while (c->parents &&
hashcmp(c->object.sha1, sb.final->object.sha1)) {
oidcmp(&c->object.oid, &sb.final->object.oid)) {
struct commit_list *l = xcalloc(1, sizeof(*l));

l->item = c;
Expand All @@ -2750,11 +2750,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
c = c->parents->item;
}

if (hashcmp(c->object.sha1, sb.final->object.sha1))
if (oidcmp(&c->object.oid, &sb.final->object.oid))
die("--reverse --first-parent together require range along first-parent chain");
}

if (is_null_sha1(sb.final->object.sha1)) {
if (is_null_oid(&sb.final->object.oid)) {
o = sb.final->util;
sb.final_buf = xmemdupz(o->file.ptr, o->file.size);
sb.final_buf_size = o->file.size;
Expand Down
12 changes: 6 additions & 6 deletions builtin/checkout.c
Expand Up @@ -56,8 +56,8 @@ static int post_checkout_hook(struct commit *old, struct commit *new,
int changed)
{
return run_hook_le(NULL, "post-checkout",
sha1_to_hex(old ? old->object.sha1 : null_sha1),
sha1_to_hex(new ? new->object.sha1 : null_sha1),
sha1_to_hex(old ? old->object.oid.hash : null_sha1),
sha1_to_hex(new ? new->object.oid.hash : null_sha1),
changed ? "1" : "0", NULL);
/* "new" can be NULL when checking out from the index before
a commit exists. */
Expand Down Expand Up @@ -513,7 +513,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
get_object_hash(old->commit->object) :
EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.sha1);
tree = parse_tree_indirect(new->commit->object.oid.hash);
init_tree_desc(&trees[1], tree->buffer, tree->size);

ret = unpack_trees(2, trees, &topts);
Expand Down Expand Up @@ -641,7 +641,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,

old_desc = old->name;
if (!old_desc && old->commit)
old_desc = sha1_to_hex(old->commit->object.sha1);
old_desc = oid_to_hex(&old->commit->object.oid);

reflog_msg = getenv("GIT_REFLOG_ACTION");
if (!reflog_msg)
Expand Down Expand Up @@ -780,10 +780,10 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
setup_revisions(0, NULL, &revs, NULL);

object->flags &= ~UNINTERESTING;
add_pending_object(&revs, object, sha1_to_hex(object->sha1));
add_pending_object(&revs, object, oid_to_hex(&object->oid));

for_each_ref(add_pending_uninteresting_ref, &revs);
add_pending_sha1(&revs, "HEAD", new->object.sha1, UNINTERESTING);
add_pending_sha1(&revs, "HEAD", new->object.oid.hash, UNINTERESTING);

refs = revs.pending;
revs.leak_pending = 1;
Expand Down
4 changes: 2 additions & 2 deletions builtin/commit-tree.c
Expand Up @@ -16,11 +16,11 @@ static const char *sign_commit;

static void new_parent(struct commit *parent, struct commit_list **parents_p)
{
unsigned char *sha1 = parent->object.sha1;
struct object_id *oid = &parent->object.oid;
struct commit_list *parents;
for (parents = *parents_p; parents; parents = parents->next) {
if (parents->item == parent) {
error("duplicate parent %s ignored", sha1_to_hex(sha1));
error("duplicate parent %s ignored", oid_to_hex(oid));
return;
}
parents_p = &parents->next;
Expand Down
14 changes: 7 additions & 7 deletions builtin/describe.c
Expand Up @@ -267,7 +267,7 @@ static void describe(const char *arg, int last_one)
}

if (!max_candidates)
die(_("no tag exactly matches '%s'"), sha1_to_hex(cmit->object.sha1));
die(_("no tag exactly matches '%s'"), oid_to_hex(&cmit->object.oid));
if (debug)
fprintf(stderr, _("searching to describe %s\n"), arg);

Expand Down Expand Up @@ -317,7 +317,7 @@ static void describe(const char *arg, int last_one)
if (annotated_cnt && !list) {
if (debug)
fprintf(stderr, _("finished search at %s\n"),
sha1_to_hex(c->object.sha1));
oid_to_hex(&c->object.oid));
break;
}
while (parents) {
Expand All @@ -334,9 +334,9 @@ static void describe(const char *arg, int last_one)
}

if (!match_cnt) {
const unsigned char *sha1 = cmit->object.sha1;
struct object_id *oid = &cmit->object.oid;
if (always) {
printf("%s", find_unique_abbrev(sha1, abbrev));
printf("%s", find_unique_abbrev(oid->hash, abbrev));
if (dirty)
printf("%s", dirty);
printf("\n");
Expand All @@ -345,11 +345,11 @@ static void describe(const char *arg, int last_one)
if (unannotated_cnt)
die(_("No annotated tags can describe '%s'.\n"
"However, there were unannotated tags: try --tags."),
sha1_to_hex(sha1));
oid_to_hex(oid));
else
die(_("No tags can describe '%s'.\n"
"Try --always, or create some tags."),
sha1_to_hex(sha1));
oid_to_hex(oid));
}

qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);
Expand All @@ -374,7 +374,7 @@ static void describe(const char *arg, int last_one)
_("more than %i tags found; listed %i most recent\n"
"gave up search at %s\n"),
max_candidates, max_candidates,
sha1_to_hex(gave_up_on->object.sha1));
oid_to_hex(&gave_up_on->object.oid));
}
}

Expand Down
4 changes: 2 additions & 2 deletions builtin/diff-tree.c
Expand Up @@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, char *line, int len)
tree2 = lookup_tree(sha1);
if (!tree2 || parse_tree(tree2))
return -1;
printf("%s %s\n", sha1_to_hex(tree1->object.sha1),
sha1_to_hex(tree2->object.sha1));
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
oid_to_hex(&tree2->object.oid));
diff_tree_sha1(get_object_hash(tree1->object), get_object_hash(tree2->object),
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
Expand Down
22 changes: 11 additions & 11 deletions builtin/fast-export.c
Expand Up @@ -544,13 +544,13 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
author = strstr(commit_buffer, "\nauthor ");
if (!author)
die ("Could not find author in commit %s",
sha1_to_hex(commit->object.sha1));
oid_to_hex(&commit->object.oid));
author++;
author_end = strchrnul(author, '\n');
committer = strstr(author_end, "\ncommitter ");
if (!committer)
die ("Could not find committer in commit %s",
sha1_to_hex(commit->object.sha1));
oid_to_hex(&commit->object.oid));
committer++;
committer_end = strchrnul(committer, '\n');
message = strstr(committer_end, "\n\n");
Expand Down Expand Up @@ -661,13 +661,13 @@ static void handle_tag(const char *name, struct tag *tag)
}
if (tagged->type == OBJ_TREE) {
warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
return;
}

buf = read_sha1_file(get_object_hash(tag->object), &type, &size);
if (!buf)
die ("Could not read tag %s", sha1_to_hex(tag->object.sha1));
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
if (message) {
message += 2;
Expand Down Expand Up @@ -706,16 +706,16 @@ static void handle_tag(const char *name, struct tag *tag)
case ABORT:
die ("Encountered signed tag %s; use "
"--signed-tags=<mode> to handle it.",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
case WARN:
warning ("Exporting signed tag %s",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
/* fallthru */
case VERBATIM:
break;
case WARN_STRIP:
warning ("Stripping signature from tag %s",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
/* fallthru */
case STRIP:
message_size = signature + 1 - message;
Expand All @@ -731,14 +731,14 @@ static void handle_tag(const char *name, struct tag *tag)
case ABORT:
die ("Tag %s tags unexported object; use "
"--tag-of-filtered-object=<mode> to handle it.",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
case DROP:
/* Ignore this tag altogether */
return;
case REWRITE:
if (tagged->type != OBJ_COMMIT) {
die ("Tag %s tags unexported %s!",
sha1_to_hex(tag->object.sha1),
oid_to_hex(&tag->object.oid),
typename(tagged->type));
}
p = (struct commit *)tagged;
Expand All @@ -751,7 +751,7 @@ static void handle_tag(const char *name, struct tag *tag)
break;
if (!p->parents)
die ("Can't find replacement commit for tag %s\n",
sha1_to_hex(tag->object.sha1));
oid_to_hex(&tag->object.oid));
p = p->parents->item;
}
tagged_mark = get_object_mark(&p->object);
Expand Down Expand Up @@ -888,7 +888,7 @@ static void export_marks(char *file)
if (deco->base && deco->base->type == 1) {
mark = ptr_to_mark(deco->decoration);
if (fprintf(f, ":%"PRIu32" %s\n", mark,
sha1_to_hex(deco->base->sha1)) < 0) {
oid_to_hex(&deco->base->oid)) < 0) {
e = 1;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/fmt-merge-msg.c
Expand Up @@ -378,7 +378,7 @@ static void shortlog(const char *name,

if (!sb.len)
string_list_append(&subjects,
sha1_to_hex(commit->object.sha1));
oid_to_hex(&commit->object.oid));
else
string_list_append(&subjects, strbuf_detach(&sb, NULL));
}
Expand Down

0 comments on commit f2fd076

Please sign in to comment.