aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2015-11-10 02:22:29 +0000
committerJeff King <peff@peff.net>2015-11-20 08:02:05 -0500
commited1c9977cb1b63e4270ad8bdf967a2d02580aa08 (patch)
treef5b52ccae09103672c62c1c11ff0bddc78199829 /builtin
parentf2fd0760f62e79609fef7bfd7ecebb002e8e4ced (diff)
downloadgit-ed1c9977cb1b63e4270ad8bdf967a2d02580aa08.tar.gz
git-ed1c9977cb1b63e4270ad8bdf967a2d02580aa08.tar.xz
Remove get_object_hash.
Convert all instances of get_object_hash to use an appropriate reference to the hash member of the oid member of struct object. This provides no functional change, as it is essentially a macro substitution. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/blame.c24
-rw-r--r--builtin/branch.c2
-rw-r--r--builtin/checkout.c10
-rw-r--r--builtin/clone.c2
-rw-r--r--builtin/commit.c8
-rw-r--r--builtin/describe.c6
-rw-r--r--builtin/diff-tree.c8
-rw-r--r--builtin/diff.c12
-rw-r--r--builtin/fast-export.c12
-rw-r--r--builtin/fetch.c4
-rw-r--r--builtin/fmt-merge-msg.c4
-rw-r--r--builtin/fsck.c4
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/log.c18
-rw-r--r--builtin/merge-tree.c4
-rw-r--r--builtin/merge.c50
-rw-r--r--builtin/name-rev.c4
-rw-r--r--builtin/notes.c2
-rw-r--r--builtin/pack-objects.c14
-rw-r--r--builtin/pull.c2
-rw-r--r--builtin/reflog.c4
-rw-r--r--builtin/reset.c2
-rw-r--r--builtin/rev-list.c4
-rw-r--r--builtin/rev-parse.c4
-rw-r--r--builtin/show-branch.c4
-rw-r--r--builtin/unpack-objects.c2
27 files changed, 107 insertions, 107 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 28c48bd45..ffb990fad 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct origin *origin)
{
if (!is_null_sha1(origin->blob_sha1))
return 0;
- if (get_tree_entry(get_object_hash(origin->commit->object),
+ if (get_tree_entry(origin->commit->object.oid.hash,
origin->path,
origin->blob_sha1, &origin->mode))
goto error_out;
@@ -558,10 +558,10 @@ static struct origin *find_origin(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_oid(&origin->commit->object.oid))
- do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
+ do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
- diff_tree_sha1(get_object_hash(parent->tree->object),
- get_object_hash(origin->commit->tree->object),
+ diff_tree_sha1(parent->tree->object.oid.hash,
+ origin->commit->tree->object.oid.hash,
"", &diff_opts);
diffcore_std(&diff_opts);
@@ -628,10 +628,10 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_oid(&origin->commit->object.oid))
- do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
+ do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
- diff_tree_sha1(get_object_hash(parent->tree->object),
- get_object_hash(origin->commit->tree->object),
+ diff_tree_sha1(parent->tree->object.oid.hash,
+ origin->commit->tree->object.oid.hash,
"", &diff_opts);
diffcore_std(&diff_opts);
@@ -1276,10 +1276,10 @@ static void find_copy_in_parent(struct scoreboard *sb,
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
if (is_null_oid(&target->commit->object.oid))
- do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
+ do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
- diff_tree_sha1(get_object_hash(parent->tree->object),
- get_object_hash(target->commit->tree->object),
+ diff_tree_sha1(parent->tree->object.oid.hash,
+ target->commit->tree->object.oid.hash,
"", &diff_opts);
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
@@ -2077,7 +2077,7 @@ static int read_ancestry(const char *graft_file)
static int update_auto_abbrev(int auto_abbrev, struct origin *suspect)
{
- const char *uniq = find_unique_abbrev(get_object_hash(suspect->commit->object),
+ const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
auto_abbrev);
int len = strlen(uniq);
if (auto_abbrev < len)
@@ -2216,7 +2216,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
struct commit_list *parents;
for (parents = work_tree->parents; parents; parents = parents->next) {
- const unsigned char *commit_sha1 = get_object_hash(parents->item->object);
+ const unsigned char *commit_sha1 = parents->item->object.oid.hash;
unsigned char blob_sha1[20];
unsigned mode;
diff --git a/builtin/branch.c b/builtin/branch.c
index e17b5ad93..3f6c825db 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -349,7 +349,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_array_item *item,
fill_tracking_info(&stat, refname, filter->verbose > 1);
strbuf_addf(out, " %s %s%s",
- find_unique_abbrev(get_object_hash(item->commit->object), filter->abbrev),
+ find_unique_abbrev(item->commit->object.oid.hash, filter->abbrev),
stat.buf, sub);
strbuf_release(&stat);
strbuf_release(&subject);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 50fd893f7..e8110a924 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -401,7 +401,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
fprintf(stderr, "%s %s... %s\n", msg,
- find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV), sb.buf);
+ find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
}
@@ -510,7 +510,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
setup_standard_excludes(topts.dir);
}
tree = parse_tree_indirect(old->commit ?
- get_object_hash(old->commit->object) :
+ old->commit->object.oid.hash :
EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.oid.hash);
@@ -653,7 +653,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
/* Nothing to do. */
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
- update_ref(msg.buf, "HEAD", get_object_hash(new->commit->object), NULL,
+ update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
if (!opts->quiet) {
if (old->path && advice_detached_head)
@@ -704,7 +704,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
strbuf_addstr(sb,
- find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
+ find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
@@ -762,7 +762,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
" git branch <new-branch-name> %s\n\n",
/* Give ngettext() the count */
lost),
- find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
+ find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
}
/*
diff --git a/builtin/clone.c b/builtin/clone.c
index 2cb8cd81f..a0b3cd9e5 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -657,7 +657,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
} else if (our) {
struct commit *c = lookup_commit_reference(our->old_oid.hash);
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
- update_ref(msg, "HEAD", get_object_hash(c->object),
+ update_ref(msg, "HEAD", c->object.oid.hash,
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
} else if (remote) {
/*
diff --git a/builtin/commit.c b/builtin/commit.c
index 795f9d24f..6aac5e284 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -299,7 +299,7 @@ static void create_base_index(const struct commit *current_head)
opts.dst_index = &the_index;
opts.fn = oneway_merge;
- tree = parse_tree_indirect(get_object_hash(current_head->object));
+ tree = parse_tree_indirect(current_head->object.oid.hash);
if (!tree)
die(_("failed to unpack HEAD tree object"));
parse_tree(tree);
@@ -1766,7 +1766,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (!transaction ||
ref_transaction_update(transaction, "HEAD", sha1,
current_head
- ? get_object_hash(current_head->object) : null_sha1,
+ ? current_head->object.oid.hash : null_sha1,
0, sb.buf, &err) ||
ref_transaction_commit(transaction, &err)) {
rollback_index_files();
@@ -1793,10 +1793,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
cfg = init_copy_notes_for_rewrite("amend");
if (cfg) {
/* we are amending, so current_head is not NULL */
- copy_note_for_rewrite(cfg, get_object_hash(current_head->object), sha1);
+ copy_note_for_rewrite(cfg, current_head->object.oid.hash, sha1);
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
}
- run_rewrite_hook(get_object_hash(current_head->object), sha1);
+ run_rewrite_hook(current_head->object.oid.hash, sha1);
}
if (!quiet)
print_summary(prefix, sha1, !current_head);
diff --git a/builtin/describe.c b/builtin/describe.c
index 11f7300aa..8a25abe0a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -252,14 +252,14 @@ static void describe(const char *arg, int last_one)
if (!cmit)
die(_("%s is not a valid '%s' object"), arg, commit_type);
- n = find_commit_name(get_object_hash(cmit->object));
+ n = find_commit_name(cmit->object.oid.hash);
if (n && (tags || all || n->prio == 2)) {
/*
* Exact match to an existing ref.
*/
display_name(n);
if (longformat)
- show_suffix(0, n->tag ? get_object_hash(*n->tag->tagged) : sha1);
+ show_suffix(0, n->tag ? n->tag->tagged->oid.hash : sha1);
if (dirty)
printf("%s", dirty);
printf("\n");
@@ -380,7 +380,7 @@ static void describe(const char *arg, int last_one)
display_name(all_matches[0].name);
if (abbrev)
- show_suffix(all_matches[0].depth, get_object_hash(cmit->object));
+ show_suffix(all_matches[0].depth, cmit->object.oid.hash);
if (dirty)
printf("%s", dirty);
printf("\n");
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 6fef266ea..2a12b81e0 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -51,7 +51,7 @@ static int stdin_diff_trees(struct tree *tree1, char *line, int len)
return -1;
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),
+ diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
@@ -139,7 +139,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
break;
case 1:
tree1 = opt->pending.objects[0].item;
- diff_tree_commit_sha1(get_object_hash(*tree1));
+ diff_tree_commit_sha1(tree1->oid.hash);
break;
case 2:
tree1 = opt->pending.objects[0].item;
@@ -149,8 +149,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
tree2 = tree1;
tree1 = tmp;
}
- diff_tree_sha1(get_object_hash(*tree1),
- get_object_hash(*tree2),
+ diff_tree_sha1(tree1->oid.hash,
+ tree2->oid.hash,
"", &opt->diffopt);
log_tree_diff_flush(opt);
break;
diff --git a/builtin/diff.c b/builtin/diff.c
index 1afed8e27..ed0acca91 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -175,8 +175,8 @@ static int builtin_diff_tree(struct rev_info *revs,
*/
if (ent1->item->flags & UNINTERESTING)
swap = 1;
- sha1[swap] = get_object_hash(*ent0->item);
- sha1[1 - swap] = get_object_hash(*ent1->item);
+ sha1[swap] = ent0->item->oid.hash;
+ sha1[1 - swap] = ent1->item->oid.hash;
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
@@ -196,8 +196,8 @@ static int builtin_diff_combined(struct rev_info *revs,
if (!revs->dense_combined_merges && !revs->combine_merges)
revs->dense_combined_merges = revs->combine_merges = 1;
for (i = 1; i < ents; i++)
- sha1_array_append(&parents, get_object_hash(*ent[i].item));
- diff_tree_combined(get_object_hash(*ent[0].item), &parents,
+ sha1_array_append(&parents, ent[i].item->oid.hash);
+ diff_tree_combined(ent[0].item->oid.hash, &parents,
revs->dense_combined_merges, revs);
sha1_array_clear(&parents);
return 0;
@@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
const char *name = entry->name;
int flags = (obj->flags & UNINTERESTING);
if (!obj->parsed)
- obj = parse_object(get_object_hash(*obj));
+ obj = parse_object(obj->oid.hash);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
@@ -408,7 +408,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
} else if (obj->type == OBJ_BLOB) {
if (2 <= blobs)
die(_("more than two blobs given: '%s'"), name);
- hashcpy(blob[blobs].sha1, get_object_hash(*obj));
+ hashcpy(blob[blobs].sha1, obj->oid.hash);
blob[blobs].name = name;
blob[blobs].mode = entry->mode;
blobs++;
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 1337a2385..d9ac5d841 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -562,11 +562,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
get_object_mark(&commit->parents->item->object) != 0 &&
!full_tree) {
parse_commit_or_die(commit->parents->item);
- diff_tree_sha1(get_object_hash(commit->parents->item->tree->object),
- get_object_hash(commit->tree->object), "", &rev->diffopt);
+ diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
+ commit->tree->object.oid.hash, "", &rev->diffopt);
}
else
- diff_root_tree_sha1(get_object_hash(commit->tree->object),
+ diff_root_tree_sha1(commit->tree->object.oid.hash,
"", &rev->diffopt);
/* Export the referenced blobs, and remember the marks. */
@@ -665,7 +665,7 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}
- buf = read_sha1_file(get_object_hash(tag->object), &type, &size);
+ buf = read_sha1_file(tag->object.oid.hash, &type, &size);
if (!buf)
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
@@ -777,7 +777,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name)
/* handle nested tags */
while (tag && tag->object.type == OBJ_TAG) {
- parse_object(get_object_hash(tag->object));
+ parse_object(tag->object.oid.hash);
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
@@ -828,7 +828,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
case OBJ_COMMIT:
break;
case OBJ_BLOB:
- export_blob(get_object_hash(commit->object));
+ export_blob(commit->object.oid.hash);
continue;
default: /* OBJ_TAG (nested tags) is already handled */
warning("Tag points to object of unexpected type %s, skipping.",
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 471c154c5..c85f3471d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -530,7 +530,7 @@ static int update_local_ref(struct ref *ref,
if (in_merge_bases(current, updated)) {
struct strbuf quickref = STRBUF_INIT;
int r;
- strbuf_add_unique_abbrev(&quickref, get_object_hash(current->object), DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);
strbuf_addstr(&quickref, "..");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
@@ -547,7 +547,7 @@ static int update_local_ref(struct ref *ref,
} else if (force || ref->force) {
struct strbuf quickref = STRBUF_INIT;
int r;
- strbuf_add_unique_abbrev(&quickref, get_object_hash(current->object), DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);
strbuf_addstr(&quickref, "...");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 12aba984e..e5658c320 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -568,7 +568,7 @@ static void find_merge_parents(struct merge_parents *result,
if (!parent)
continue;
commit_list_insert(parent, &parents);
- add_merge_parent(result, get_object_hash(*obj), get_object_hash(parent->object));
+ add_merge_parent(result, obj->oid.hash, parent->object.oid.hash);
}
head_commit = lookup_commit(head);
if (head_commit)
@@ -578,7 +578,7 @@ static void find_merge_parents(struct merge_parents *result,
while (parents) {
struct commit *cmit = pop_commit(&parents);
for (i = 0; i < result->nr; i++)
- if (!hashcmp(result->item[i].commit, get_object_hash(cmit->object)))
+ if (!hashcmp(result->item[i].commit, cmit->object.oid.hash))
result->item[i].used = 1;
}
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 7bfb4938f..55eac756f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -186,7 +186,7 @@ static void check_reachable_object(struct object *obj)
* do a full fsck
*/
if (!(obj->flags & HAS_OBJ)) {
- if (has_sha1_pack(get_object_hash(*obj)))
+ if (has_sha1_pack(obj->oid.hash))
return; /* it is in pack - forget about it */
if (connectivity_only && has_object_file(&obj->oid))
return;
@@ -249,7 +249,7 @@ static void check_unreachable_object(struct object *obj)
if (!(f = fopen(filename, "w")))
die_errno("Could not open '%s'", filename);
if (obj->type == OBJ_BLOB) {
- if (stream_blob_to_fd(fileno(f), get_object_hash(*obj), NULL, 1))
+ if (stream_blob_to_fd(fileno(f), obj->oid.hash, NULL, 1))
die_errno("Could not write '%s'", filename);
} else
fprintf(f, "%s\n", oid_to_hex(&obj->oid));
diff --git a/builtin/grep.c b/builtin/grep.c
index ca3ceea42..2825453d1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -459,7 +459,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
struct object *obj, const char *name, const char *path)
{
if (obj->type == OBJ_BLOB)
- return grep_sha1(opt, get_object_hash(*obj), name, 0, path);
+ return grep_sha1(opt, obj->oid.hash, name, 0, path);
if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
struct tree_desc tree;
void *data;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 48b470dd7..6a0150958 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -217,7 +217,7 @@ static unsigned check_object(struct object *obj)
if (!(obj->flags & FLAG_CHECKED)) {
unsigned long size;
- int type = sha1_object_info(get_object_hash(*obj), &size);
+ int type = sha1_object_info(obj->oid.hash, &size);
if (type <= 0)
die(_("did not receive expected object %s"),
oid_to_hex(&obj->oid));
diff --git a/builtin/log.c b/builtin/log.c
index a16ec3243..069bd3a90 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -552,7 +552,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
const char *name = objects[i].name;
switch (o->type) {
case OBJ_BLOB:
- ret = show_blob_object(get_object_hash(*o), &rev, name);
+ ret = show_blob_object(o->oid.hash, &rev, name);
break;
case OBJ_TAG: {
struct tag *t = (struct tag *)o;
@@ -563,11 +563,11 @@ int cmd_show(int argc, const char **argv, const char *prefix)
diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
- ret = show_tag_object(get_object_hash(*o), &rev);
+ ret = show_tag_object(o->oid.hash, &rev);
rev.shown_one = 1;
if (ret)
break;
- o = parse_object(get_object_hash(*t->tagged));
+ o = parse_object(t->tagged->oid.hash);
if (!o)
ret = error(_("Could not read object %s"),
oid_to_hex(&t->tagged->oid));
@@ -830,8 +830,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
o2 = rev->pending.objects[1].item;
flags1 = o1->flags;
flags2 = o2->flags;
- c1 = lookup_commit_reference(get_object_hash(*o1));
- c2 = lookup_commit_reference(get_object_hash(*o2));
+ c1 = lookup_commit_reference(o1->oid.hash);
+ c2 = lookup_commit_reference(o2->oid.hash);
if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
die(_("Not a range."));
@@ -993,8 +993,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
diff_setup_done(&opts);
- diff_tree_sha1(get_object_hash(origin->tree->object),
- get_object_hash(head->tree->object),
+ diff_tree_sha1(origin->tree->object.oid.hash,
+ head->tree->object.oid.hash,
"", &opts);
diffcore_std(&opts);
diff_flush(&opts);
@@ -1612,12 +1612,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
{
if (!verbose) {
printf("%c %s\n", sign,
- find_unique_abbrev(get_object_hash(commit->object), abbrev));
+ find_unique_abbrev(commit->object.oid.hash, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
printf("%c %s %s\n", sign,
- find_unique_abbrev(get_object_hash(commit->object), abbrev),
+ find_unique_abbrev(commit->object.oid.hash, abbrev),
buf.buf);
strbuf_release(&buf);
}
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index e124886ef..d4f0cbd45 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -60,7 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
const char *path = entry->path;
if (!entry->stage)
- return read_sha1_file(get_object_hash(entry->blob->object), &type, size);
+ return read_sha1_file(entry->blob->object.oid.hash, &type, size);
base = NULL;
if (entry->stage == 1) {
base = entry->blob;
@@ -82,7 +82,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
enum object_type type;
while (entry) {
if (entry->stage == 2)
- return read_sha1_file(get_object_hash(entry->blob->object), &type, size);
+ return read_sha1_file(entry->blob->object.oid.hash, &type, size);
entry = entry->link;
}
return NULL;
diff --git a/builtin/merge.c b/builtin/merge.c
index c804218fb..15bf95b3a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -380,7 +380,7 @@ static void finish(struct commit *head_commit,
const unsigned char *new_head, const char *msg)
{
struct strbuf reflog_message = STRBUF_INIT;
- const unsigned char *head = get_object_hash(head_commit->object);
+ const unsigned char *head = head_commit->object.oid.hash;
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
@@ -497,7 +497,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (ref_exists(truname.buf)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
- sha1_to_hex(get_object_hash(remote_head->object)),
+ sha1_to_hex(remote_head->object.oid.hash),
truname.buf + 11,
(early ? " (early part)" : ""));
strbuf_release(&truname);
@@ -511,7 +511,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
desc = merge_remote_util(remote_head);
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
strbuf_addf(msg, "%s\t\t%s '%s'\n",
- sha1_to_hex(get_object_hash(*desc->obj)),
+ sha1_to_hex(desc->obj->oid.hash),
typename(desc->obj->type),
remote);
goto cleanup;
@@ -519,7 +519,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
}
strbuf_addf(msg, "%s\t\tcommit '%s'\n",
- sha1_to_hex(get_object_hash(remote_head->object)), remote);
+ sha1_to_hex(remote_head->object.oid.hash), remote);
cleanup:
strbuf_release(&buf);
strbuf_release(&bname);
@@ -892,7 +892,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv,
second_token = lookup_commit_reference_gently(second_sha1, 0);
if (!second_token)
die(_("'%s' is not a commit"), argv[1]);
- if (hashcmp(get_object_hash(second_token->object), head))
+ if (hashcmp(second_token->object.oid.hash, head))
return NULL;
}
return second_token;
@@ -1274,8 +1274,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die(_("%s - not something we can merge"), argv[0]);
if (remoteheads->next)
die(_("Can merge only exactly one commit into empty head"));
- read_empty(get_object_hash(remote_head->object), 0);
- update_ref("initial pull", "HEAD", get_object_hash(remote_head->object),
+ read_empty(remote_head->object.oid.hash, 0);
+ update_ref("initial pull", "HEAD", remote_head->object.oid.hash,
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
goto done;
}
@@ -1289,7 +1289,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* additional safety measure to check for it.
*/
if (!have_message &&
- is_old_style_invocation(argc, argv, get_object_hash(head_commit->object))) {
+ is_old_style_invocation(argc, argv, head_commit->object.oid.hash)) {
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
strbuf_addstr(&merge_msg, argv[0]);
head_arg = argv[1];
@@ -1323,7 +1323,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
check_commit_signature(commit, &signature_check);
- find_unique_abbrev_r(hex, get_object_hash(commit->object), DEFAULT_ABBREV);
+ find_unique_abbrev_r(hex, commit->object.oid.hash, DEFAULT_ABBREV);
switch (signature_check.result) {
case 'G':
break;
@@ -1353,7 +1353,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
for (p = remoteheads; p; p = p->next) {
struct commit *commit = p->item;
strbuf_addf(&buf, "GITHEAD_%s",
- sha1_to_hex(get_object_hash(commit->object)));
+ sha1_to_hex(commit->object.oid.hash));
setenv(buf.buf, merge_remote_util(commit)->name, 1);
strbuf_reset(&buf);
if (fast_forward != FF_ONLY &&
@@ -1393,7 +1393,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
free(list);
}
- update_ref("updating ORIG_HEAD", "ORIG_HEAD", get_object_hash(head_commit->object),
+ update_ref("updating ORIG_HEAD", "ORIG_HEAD", head_commit->object.oid.hash,
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
if (remoteheads && !common)
@@ -1409,16 +1409,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
} else if (fast_forward != FF_NO && !remoteheads->next &&
!common->next &&
- !hashcmp(get_object_hash(common->item->object), get_object_hash(head_commit->object))) {
+ !hashcmp(common->item->object.oid.hash, head_commit->object.oid.hash)) {
/* Again the most common case of merging one remote. */
struct strbuf msg = STRBUF_INIT;
struct commit *commit;
if (verbosity >= 0) {
char from[GIT_SHA1_HEXSZ + 1], to[GIT_SHA1_HEXSZ + 1];
- find_unique_abbrev_r(from, get_object_hash(head_commit->object),
+ find_unique_abbrev_r(from, head_commit->object.oid.hash,
DEFAULT_ABBREV);
- find_unique_abbrev_r(to, get_object_hash(remoteheads->item->object),
+ find_unique_abbrev_r(to, remoteheads->item->object.oid.hash,
DEFAULT_ABBREV);
printf(_("Updating %s..%s\n"), from, to);
}
@@ -1432,14 +1432,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
- if (checkout_fast_forward(get_object_hash(head_commit->object),
- get_object_hash(commit->object),
+ if (checkout_fast_forward(head_commit->object.oid.hash,
+ commit->object.oid.hash,
overwrite_ignore)) {
ret = 1;
goto done;
}
- finish(head_commit, remoteheads, get_object_hash(commit->object), msg.buf);
+ finish(head_commit, remoteheads, commit->object.oid.hash, msg.buf);
drop_save();
goto done;
} else if (!remoteheads->next && common->next)
@@ -1458,9 +1458,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
/* See if it is really trivial. */
git_committer_info(IDENT_STRICT);
printf(_("Trying really trivial in-index merge...\n"));
- if (!read_tree_trivial(get_object_hash(common->item->object),
- get_object_hash(head_commit->object),
- get_object_hash(remoteheads->item->object))) {
+ if (!read_tree_trivial(common->item->object.oid.hash,
+ head_commit->object.oid.hash,
+ remoteheads->item->object.oid.hash)) {
ret = merge_trivial(head_commit, remoteheads);
goto done;
}
@@ -1483,8 +1483,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* HEAD^^" would be missed.
*/
common_one = get_merge_bases(head_commit, j->item);
- if (hashcmp(get_object_hash(common_one->item->object),
- get_object_hash(j->item->object))) {
+ if (hashcmp(common_one->item->object.oid.hash,
+ j->item->object.oid.hash)) {
up_to_date = 0;
break;
}
@@ -1520,7 +1520,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
int ret;
if (i) {
printf(_("Rewinding the tree to pristine...\n"));
- restore_state(get_object_hash(head_commit->object), stash);
+ restore_state(head_commit->object.oid.hash, stash);
}
if (use_strategies_nr != 1)
printf(_("Trying merge strategy %s...\n"),
@@ -1586,7 +1586,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* it up.
*/
if (!best_strategy) {
- restore_state(get_object_hash(head_commit->object), stash);
+ restore_state(head_commit->object.oid.hash, stash);
if (use_strategies_nr > 1)
fprintf(stderr,
_("No merge strategy handled the merge.\n"));
@@ -1599,7 +1599,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
; /* We already have its result in the working tree. */
else {
printf(_("Rewinding the tree to pristine...\n"));
- restore_state(get_object_hash(head_commit->object), stash);
+ restore_state(head_commit->object.oid.hash, stash);
printf(_("Using the %s to prepare resolving by hand.\n"),
best_strategy);
try_merge_strategy(best_strategy, common, remoteheads,
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 49e6e91b1..092e03c3c 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -162,7 +162,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
struct tag *t = (struct tag *) o;
if (!t->tagged)
break; /* broken repository */
- o = parse_object(get_object_hash(*t->tagged));
+ o = parse_object(t->tagged->oid.hash);
deref = 1;
}
if (o && o->type == OBJ_COMMIT) {
@@ -193,7 +193,7 @@ static const char *get_exact_ref_match(const struct object *o)
tip_table.sorted = 1;
}
- found = sha1_pos(get_object_hash(*o), tip_table.table, tip_table.nr,
+ found = sha1_pos(o->oid.hash, tip_table.table, tip_table.nr,
nth_tip_table_ent);
if (0 <= found)
return tip_table.table[found].refname;
diff --git a/builtin/notes.c b/builtin/notes.c
index 1a6785920..52aa9af74 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -707,7 +707,7 @@ static int merge_commit(struct notes_merge_options *o)
die("Could not parse commit from NOTES_MERGE_PARTIAL.");
if (partial->parents)
- hashcpy(parent_sha1, get_object_hash(partial->parents->item->object));
+ hashcpy(parent_sha1, partial->parents->item->object.oid.hash);
else
hashclr(parent_sha1);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index fa1b5cd71..4dae5b11c 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2277,7 +2277,7 @@ static void read_object_list_from_stdin(void)
static void show_commit(struct commit *commit, void *data)
{
- add_object_entry(get_object_hash(commit->object), OBJ_COMMIT, NULL, 0);
+ add_object_entry(commit->object.oid.hash, OBJ_COMMIT, NULL, 0);
commit->object.flags |= OBJECT_ADDED;
if (write_bitmap_index)
@@ -2291,7 +2291,7 @@ static void show_object(struct object *obj,
char *name = path_name(path, last);
add_preferred_base_object(name);
- add_object_entry(get_object_hash(*obj), obj->type, name, 0);
+ add_object_entry(obj->oid.hash, obj->type, name, 0);
obj->flags |= OBJECT_ADDED;
/*
@@ -2303,7 +2303,7 @@ static void show_object(struct object *obj,
static void show_edge(struct commit *commit)
{
- add_preferred_base(get_object_hash(commit->object));
+ add_preferred_base(commit->object.oid.hash);
}
struct in_pack_object {
@@ -2319,7 +2319,7 @@ struct in_pack {
static void mark_in_pack_object(struct object *object, struct packed_git *p, struct in_pack *in_pack)
{
- in_pack->array[in_pack->nr].offset = find_pack_entry_one(get_object_hash(*object), p);
+ in_pack->array[in_pack->nr].offset = find_pack_entry_one(object->oid.hash, p);
in_pack->array[in_pack->nr].object = object;
in_pack->nr++;
}
@@ -2376,7 +2376,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
ofscmp);
for (i = 0; i < in_pack.nr; i++) {
struct object *o = in_pack.array[i].object;
- add_object_entry(get_object_hash(*o), o->type, "", 0);
+ add_object_entry(o->oid.hash, o->type, "", 0);
}
}
free(in_pack.array);
@@ -2484,12 +2484,12 @@ static void record_recent_object(struct object *obj,
const char *last,
void *data)
{
- sha1_array_append(&recent_objects, get_object_hash(*obj));
+ sha1_array_append(&recent_objects, obj->oid.hash);
}
static void record_recent_commit(struct commit *commit, void *data)
{
- sha1_array_append(&recent_objects, get_object_hash(commit->object));
+ sha1_array_append(&recent_objects, commit->object.oid.hash);
}
static void get_object_list(int ac, const char **av)
diff --git a/builtin/pull.c b/builtin/pull.c
index 4b7e344ac..5145fc60a 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -743,7 +743,7 @@ static int get_octopus_merge_base(unsigned char *merge_base,
if (!result)
return 1;
- hashcpy(merge_base, get_object_hash(result->item->object));
+ hashcpy(merge_base, result->item->object.oid.hash);
return 0;
}
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 9b8f9bbb9..f39960e5e 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -126,7 +126,7 @@ static int commit_is_complete(struct commit *commit)
struct commit_list *parent;
c = (struct commit *)study.objects[--study.nr].item;
- if (!c->object.parsed && !parse_object(get_object_hash(c->object)))
+ if (!c->object.parsed && !parse_object(c->object.oid.hash))
c->object.flags |= INCOMPLETE;
if (c->object.flags & INCOMPLETE) {
@@ -152,7 +152,7 @@ static int commit_is_complete(struct commit *commit)
for (i = 0; i < found.nr; i++) {
struct commit *c =
(struct commit *)found.objects[i].item;
- if (!tree_is_complete(get_object_hash(c->tree->object))) {
+ if (!tree_is_complete(c->tree->object.oid.hash)) {
is_incomplete = 1;
c->object.flags |= INCOMPLETE;
}
diff --git a/builtin/reset.c b/builtin/reset.c
index d0014b625..092c3a539 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -96,7 +96,7 @@ static void print_new_head_line(struct commit *commit)
const char *hex, *body;
const char *msg;
- hex = find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV);
+ hex = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
body = strstr(msg, "\n\n");
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index c4166ea7d..3aa89a1a3 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -81,7 +81,7 @@ static void show_commit(struct commit *commit, void *data)
if (!revs->graph)
fputs(get_revision_mark(revs, commit), stdout);
if (revs->abbrev_commit && revs->abbrev)
- fputs(find_unique_abbrev(get_object_hash(commit->object), revs->abbrev),
+ fputs(find_unique_abbrev(commit->object.oid.hash, revs->abbrev),
stdout);
else
fputs(oid_to_hex(&commit->object.oid), stdout);
@@ -185,7 +185,7 @@ static void finish_object(struct object *obj,
if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid))
die("missing blob object '%s'", oid_to_hex(&obj->oid));
if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
- parse_object(get_object_hash(*obj));
+ parse_object(obj->oid.hash);
}
static void show_object(struct object *obj,
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 9985949cc..7e074aad4 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -282,7 +282,7 @@ static int try_difference(const char *arg)
exclude = get_merge_bases(a, b);
while (exclude) {
struct commit *commit = pop_commit(&exclude);
- show_rev(REVERSED, get_object_hash(commit->object), NULL);
+ show_rev(REVERSED, commit->object.oid.hash, NULL);
}
}
*dotdot = '.';
@@ -319,7 +319,7 @@ static int try_parent_shorthands(const char *arg)
commit = lookup_commit_reference(sha1);
for (parents = commit->parents; parents; parents = parents->next)
show_rev(parents_only ? NORMAL : REVERSED,
- get_object_hash(parents->item->object), arg);
+ parents->item->object.oid.hash, arg);
*dotdot = '^';
return 1;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 182864090..25669357e 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -291,7 +291,7 @@ static void show_one_commit(struct commit *commit, int no_name)
}
else
printf("[%s] ",
- find_unique_abbrev(get_object_hash(commit->object),
+ find_unique_abbrev(commit->object.oid.hash,
DEFAULT_ABBREV));
}
puts(pretty_str);
@@ -867,7 +867,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
head_len,
ref_name[i],
head_oid.hash,
- get_object_hash(rev[i]->object));
+ rev[i]->object.oid.hash);
if (extra < 0)
printf("%c [%s] ",
is_head ? '*' : ' ', ref_name[i]);
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 61a337889..875e7ed99 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -194,7 +194,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op
if (!(obj->flags & FLAG_OPEN)) {
unsigned long size;
- int type = sha1_object_info(get_object_hash(*obj), &size);
+ int type = sha1_object_info(obj->oid.hash, &size);
if (type != obj->type || type <= 0)
die("object of unexpected type");
obj->flags |= FLAG_WRITTEN;