Skip to content

Commit 6b526ce

Browse files
committed
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 ...
2 parents f382b75 + c251c83 commit 6b526ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1173
-1134
lines changed

archive.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void parse_treeish_arg(const char **argv,
360360
if (get_sha1(name, oid.hash))
361361
die("Not a valid object name");
362362

363-
commit = lookup_commit_reference_gently(oid.hash, 1);
363+
commit = lookup_commit_reference_gently(&oid, 1);
364364
if (commit) {
365365
commit_sha1 = commit->object.oid.hash;
366366
archive_time = commit->date;
@@ -369,7 +369,7 @@ static void parse_treeish_arg(const char **argv,
369369
archive_time = time(NULL);
370370
}
371371

372-
tree = parse_tree_indirect(oid.hash);
372+
tree = parse_tree_indirect(&oid);
373373
if (tree == NULL)
374374
die("not a tree object");
375375

@@ -383,7 +383,7 @@ static void parse_treeish_arg(const char **argv,
383383
if (err || !S_ISDIR(mode))
384384
die("current working directory is untracked");
385385

386-
tree = parse_tree_indirect(tree_oid.hash);
386+
tree = parse_tree_indirect(&tree_oid);
387387
}
388388
ar_args->tree = tree;
389389
ar_args->commit_sha1 = commit_sha1;

bisect.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
705705

706706
static struct commit *get_commit_reference(const struct object_id *oid)
707707
{
708-
struct commit *r = lookup_commit_reference(oid->hash);
708+
struct commit *r = lookup_commit_reference(oid);
709709
if (!r)
710710
die(_("Not a valid commit name %s"), oid_to_hex(oid));
711711
return r;

blob.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
const char *blob_type = "blob";
55

6-
struct blob *lookup_blob(const unsigned char *sha1)
6+
struct blob *lookup_blob(const struct object_id *oid)
77
{
8-
struct object *obj = lookup_object(sha1);
8+
struct object *obj = lookup_object(oid->hash);
99
if (!obj)
10-
return create_object(sha1, alloc_blob_node());
10+
return create_object(oid->hash, alloc_blob_node());
1111
return object_as_type(obj, OBJ_BLOB, 0);
1212
}
1313

blob.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct blob {
99
struct object object;
1010
};
1111

12-
struct blob *lookup_blob(const unsigned char *sha1);
12+
struct blob *lookup_blob(const struct object_id *oid);
1313

1414
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
1515

branch.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
191191

192192
if (!attr_only) {
193193
const char *head;
194-
unsigned char sha1[20];
194+
struct object_id oid;
195195

196-
head = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
196+
head = resolve_ref_unsafe("HEAD", 0, oid.hash, NULL);
197197
if (!is_bare_repository() && head && !strcmp(head, ref->buf))
198198
die(_("Cannot force update the current branch."));
199199
}
@@ -233,7 +233,7 @@ void create_branch(const char *name, const char *start_name,
233233
int quiet, enum branch_track track)
234234
{
235235
struct commit *commit;
236-
unsigned char sha1[20];
236+
struct object_id oid;
237237
char *real_ref;
238238
struct strbuf ref = STRBUF_INIT;
239239
int forcing = 0;
@@ -253,7 +253,7 @@ void create_branch(const char *name, const char *start_name,
253253
}
254254

255255
real_ref = NULL;
256-
if (get_sha1(start_name, sha1)) {
256+
if (get_oid(start_name, &oid)) {
257257
if (explicit_tracking) {
258258
if (advice_set_upstream_failure) {
259259
error(_(upstream_missing), start_name);
@@ -265,7 +265,7 @@ void create_branch(const char *name, const char *start_name,
265265
die(_("Not a valid object name: '%s'."), start_name);
266266
}
267267

268-
switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {
268+
switch (dwim_ref(start_name, strlen(start_name), oid.hash, &real_ref)) {
269269
case 0:
270270
/* Not branching from any existing branch */
271271
if (explicit_tracking)
@@ -286,9 +286,9 @@ void create_branch(const char *name, const char *start_name,
286286
break;
287287
}
288288

289-
if ((commit = lookup_commit_reference(sha1)) == NULL)
289+
if ((commit = lookup_commit_reference(&oid)) == NULL)
290290
die(_("Not a valid branch point: '%s'."), start_name);
291-
hashcpy(sha1, commit->object.oid.hash);
291+
oidcpy(&oid, &commit->object.oid);
292292

293293
if (reflog)
294294
log_all_ref_updates = LOG_REFS_NORMAL;
@@ -306,7 +306,7 @@ void create_branch(const char *name, const char *start_name,
306306
transaction = ref_transaction_begin(&err);
307307
if (!transaction ||
308308
ref_transaction_update(transaction, ref.buf,
309-
sha1, forcing ? NULL : null_sha1,
309+
oid.hash, forcing ? NULL : null_sha1,
310310
0, msg, &err) ||
311311
ref_transaction_commit(transaction, &err))
312312
die("%s", err.buf);

builtin/am.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ static int index_has_changes(struct strbuf *sb)
11451145
DIFF_OPT_SET(&opt, EXIT_WITH_STATUS);
11461146
if (!sb)
11471147
DIFF_OPT_SET(&opt, QUICK);
1148-
do_diff_cache(head.hash, &opt);
1148+
do_diff_cache(&head, &opt);
11491149
diffcore_std(&opt);
11501150
for (i = 0; sb && i < diff_queued_diff.nr; i++) {
11511151
if (i)
@@ -1447,9 +1447,9 @@ static void write_index_patch(const struct am_state *state)
14471447
FILE *fp;
14481448

14491449
if (!get_sha1_tree("HEAD", head.hash))
1450-
tree = lookup_tree(head.hash);
1450+
tree = lookup_tree(&head);
14511451
else
1452-
tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
1452+
tree = lookup_tree(&empty_tree_oid);
14531453

14541454
fp = xfopen(am_path(state, "patch"), "w");
14551455
init_revisions(&rev_info, NULL);
@@ -1482,7 +1482,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
14821482
if (get_mail_commit_oid(&commit_oid, mail) < 0)
14831483
die(_("could not parse %s"), mail);
14841484

1485-
commit = lookup_commit_or_die(commit_oid.hash, mail);
1485+
commit = lookup_commit_or_die(&commit_oid, mail);
14861486

14871487
get_commit_info(state, commit);
14881488

@@ -1612,7 +1612,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
16121612
init_revisions(&rev_info, NULL);
16131613
rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;
16141614
diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix);
1615-
add_pending_sha1(&rev_info, "HEAD", our_tree.hash, 0);
1615+
add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
16161616
diff_setup_done(&rev_info.diffopt);
16171617
run_diff_index(&rev_info, 1);
16181618
}
@@ -1677,7 +1677,7 @@ static void do_commit(const struct am_state *state)
16771677

16781678
if (!get_sha1_commit("HEAD", parent.hash)) {
16791679
old_oid = &parent;
1680-
commit_list_insert(lookup_commit(parent.hash), &parents);
1680+
commit_list_insert(lookup_commit(&parent), &parents);
16811681
} else {
16821682
old_oid = NULL;
16831683
say(state, stderr, _("applying to an empty history"));
@@ -2039,11 +2039,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
20392039
struct tree *head_tree, *remote_tree, *index_tree;
20402040
struct object_id index;
20412041

2042-
head_tree = parse_tree_indirect(head->hash);
2042+
head_tree = parse_tree_indirect(head);
20432043
if (!head_tree)
20442044
return error(_("Could not parse object '%s'."), oid_to_hex(head));
20452045

2046-
remote_tree = parse_tree_indirect(remote->hash);
2046+
remote_tree = parse_tree_indirect(remote);
20472047
if (!remote_tree)
20482048
return error(_("Could not parse object '%s'."), oid_to_hex(remote));
20492049

@@ -2055,7 +2055,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem
20552055
if (write_cache_as_tree(index.hash, 0, NULL))
20562056
return -1;
20572057

2058-
index_tree = parse_tree_indirect(index.hash);
2058+
index_tree = parse_tree_indirect(&index);
20592059
if (!index_tree)
20602060
return error(_("Could not parse object '%s'."), oid_to_hex(&index));
20612061

builtin/blame.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static struct origin *find_origin(struct scoreboard *sb,
563563
diff_setup_done(&diff_opts);
564564

565565
if (is_null_oid(&origin->commit->object.oid))
566-
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
566+
do_diff_cache(&parent->tree->object.oid, &diff_opts);
567567
else
568568
diff_tree_sha1(parent->tree->object.oid.hash,
569569
origin->commit->tree->object.oid.hash,
@@ -633,7 +633,7 @@ static struct origin *find_rename(struct scoreboard *sb,
633633
diff_setup_done(&diff_opts);
634634

635635
if (is_null_oid(&origin->commit->object.oid))
636-
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
636+
do_diff_cache(&parent->tree->object.oid, &diff_opts);
637637
else
638638
diff_tree_sha1(parent->tree->object.oid.hash,
639639
origin->commit->tree->object.oid.hash,
@@ -1272,7 +1272,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
12721272
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
12731273

12741274
if (is_null_oid(&target->commit->object.oid))
1275-
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
1275+
do_diff_cache(&parent->tree->object.oid, &diff_opts);
12761276
else
12771277
diff_tree_sha1(parent->tree->object.oid.hash,
12781278
target->commit->tree->object.oid.hash,
@@ -2253,7 +2253,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
22532253
{
22542254
struct commit *parent;
22552255

2256-
parent = lookup_commit_reference(oid->hash);
2256+
parent = lookup_commit_reference(oid);
22572257
if (!parent)
22582258
die("no such commit %s", oid_to_hex(oid));
22592259
return &commit_list_insert(parent, tail)->next;
@@ -2461,7 +2461,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
24612461
*/
24622462
struct object *obj;
24632463
struct commit *head_commit;
2464-
unsigned char head_sha1[20];
2464+
struct object_id head_oid;
24652465

24662466
if (sb->revs->pending.nr != 1)
24672467
return NULL;
@@ -2473,9 +2473,9 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
24732473
return NULL;
24742474

24752475
/* Do we have HEAD? */
2476-
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
2476+
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
24772477
return NULL;
2478-
head_commit = lookup_commit_reference_gently(head_sha1, 1);
2478+
head_commit = lookup_commit_reference_gently(&head_oid, 1);
24792479
if (!head_commit)
24802480
return NULL;
24812481

builtin/branch.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int branch_merged(int kind, const char *name,
124124
(reference_name = reference_name_to_free =
125125
resolve_refdup(upstream, RESOLVE_REF_READING,
126126
oid.hash, NULL)) != NULL)
127-
reference_rev = lookup_commit_reference(oid.hash);
127+
reference_rev = lookup_commit_reference(&oid);
128128
}
129129
if (!reference_rev)
130130
reference_rev = head_rev;
@@ -157,7 +157,7 @@ static int check_branch_commit(const char *branchname, const char *refname,
157157
const struct object_id *oid, struct commit *head_rev,
158158
int kinds, int force)
159159
{
160-
struct commit *rev = lookup_commit_reference(oid->hash);
160+
struct commit *rev = lookup_commit_reference(oid);
161161
if (!rev) {
162162
error(_("Couldn't look up commit object for '%s'"), refname);
163163
return -1;
@@ -211,7 +211,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
211211
}
212212

213213
if (!force) {
214-
head_rev = lookup_commit_reference(head_oid.hash);
214+
head_rev = lookup_commit_reference(&head_oid);
215215
if (!head_rev)
216216
die(_("Couldn't look up commit object for HEAD"));
217217
}

builtin/checkout.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static int checkout_paths(const struct checkout_opts *opts,
393393
die(_("unable to write new index file"));
394394

395395
read_ref_full("HEAD", 0, rev.hash, NULL);
396-
head = lookup_commit_reference_gently(rev.hash, 1);
396+
head = lookup_commit_reference_gently(&rev, 1);
397397

398398
errs |= post_checkout_hook(head, head, 0);
399399
return errs;
@@ -527,10 +527,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
527527
setup_standard_excludes(topts.dir);
528528
}
529529
tree = parse_tree_indirect(old->commit ?
530-
old->commit->object.oid.hash :
531-
EMPTY_TREE_SHA1_BIN);
530+
&old->commit->object.oid :
531+
&empty_tree_oid);
532532
init_tree_desc(&trees[0], tree->buffer, tree->size);
533-
tree = parse_tree_indirect(new->commit->object.oid.hash);
533+
tree = parse_tree_indirect(&new->commit->object.oid);
534534
init_tree_desc(&trees[1], tree->buffer, tree->size);
535535

536536
ret = unpack_trees(2, trees, &topts);
@@ -721,7 +721,7 @@ static int add_pending_uninteresting_ref(const char *refname,
721721
const struct object_id *oid,
722722
int flags, void *cb_data)
723723
{
724-
add_pending_sha1(cb_data, refname, oid->hash, UNINTERESTING);
724+
add_pending_oid(cb_data, refname, oid, UNINTERESTING);
725725
return 0;
726726
}
727727

@@ -807,7 +807,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new)
807807
add_pending_object(&revs, object, oid_to_hex(&object->oid));
808808

809809
for_each_ref(add_pending_uninteresting_ref, &revs);
810-
add_pending_sha1(&revs, "HEAD", new->object.oid.hash, UNINTERESTING);
810+
add_pending_oid(&revs, "HEAD", &new->object.oid, UNINTERESTING);
811811

812812
refs = revs.pending;
813813
revs.leak_pending = 1;
@@ -834,7 +834,7 @@ static int switch_branches(const struct checkout_opts *opts,
834834
memset(&old, 0, sizeof(old));
835835
old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
836836
if (old.path)
837-
old.commit = lookup_commit_reference_gently(rev.hash, 1);
837+
old.commit = lookup_commit_reference_gently(&rev, 1);
838838
if (!(flag & REF_ISSYMREF))
839839
old.path = NULL;
840840

@@ -1048,10 +1048,10 @@ static int parse_branchname_arg(int argc, const char **argv,
10481048
else
10491049
new->path = NULL; /* not an existing branch */
10501050

1051-
new->commit = lookup_commit_reference_gently(rev->hash, 1);
1051+
new->commit = lookup_commit_reference_gently(rev, 1);
10521052
if (!new->commit) {
10531053
/* not a commit */
1054-
*source_tree = parse_tree_indirect(rev->hash);
1054+
*source_tree = parse_tree_indirect(rev);
10551055
} else {
10561056
parse_commit_or_die(new->commit);
10571057
*source_tree = new->commit->tree;

builtin/clone.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
685685
install_branch_config(0, head, option_origin, our->name);
686686
}
687687
} else if (our) {
688-
struct commit *c = lookup_commit_reference(our->old_oid.hash);
688+
struct commit *c = lookup_commit_reference(&our->old_oid);
689689
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
690690
update_ref(msg, "HEAD", c->object.oid.hash,
691691
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
@@ -742,7 +742,7 @@ static int checkout(int submodule_progress)
742742
opts.src_index = &the_index;
743743
opts.dst_index = &the_index;
744744

745-
tree = parse_tree_indirect(oid.hash);
745+
tree = parse_tree_indirect(&oid);
746746
parse_tree(tree);
747747
init_tree_desc(&t, tree->buffer, tree->size);
748748
if (unpack_trees(1, &t, &opts) < 0)

builtin/commit-tree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
5858
if (get_sha1_commit(argv[i], oid.hash))
5959
die("Not a valid object name %s", argv[i]);
6060
assert_sha1_type(oid.hash, OBJ_COMMIT);
61-
new_parent(lookup_commit(oid.hash), &parents);
61+
new_parent(lookup_commit(&oid), &parents);
6262
continue;
6363
}
6464

0 commit comments

Comments
 (0)