{
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;
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);
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);
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))
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)
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;
return commit;
}
-static struct object_array_entry *find_single_final(struct rev_info *revs)
+static struct commit *find_single_final(struct rev_info *revs,
+ const char **name_p)
{
int i;
- struct object_array_entry *found = NULL;
+ struct commit *found = NULL;
+ const char *name = NULL;
for (i = 0; i < revs->pending.nr; i++) {
struct object *obj = revs->pending.objects[i].item;
die("Non commit %s?", revs->pending.objects[i].name);
if (found)
die("More than one commit to dig from %s and %s?",
- revs->pending.objects[i].name,
- found->name);
- found = &(revs->pending.objects[i]);
+ revs->pending.objects[i].name, name);
+ found = (struct commit *)obj;
+ name = revs->pending.objects[i].name;
}
+ if (name_p)
+ *name_p = name;
return found;
}
static char *prepare_final(struct scoreboard *sb)
{
- struct object_array_entry *found = find_single_final(sb->revs);
- if (found) {
- sb->final = (struct commit *) found->item;
- return xstrdup(found->name);
- } else {
- return NULL;
- }
+ const char *name;
+ sb->final = find_single_final(sb->revs, &name);
+ return xstrdup_or_null(name);
}
static char *prepare_initial(struct scoreboard *sb)
die("Cannot use --contents with final commit object name");
if (reverse && revs.first_parent_only) {
- struct object_array_entry *entry = find_single_final(sb.revs);
- if (!entry)
+ final_commit = find_single_final(sb.revs, NULL);
+ if (!final_commit)
die("--reverse and --first-parent together require specified latest commit");
- else
- final_commit = (struct commit*) entry->item;
}
/*