Skip to content

Commit ef8aa26

Browse files
committed
Merge branch 'bc/object-id' into next
Conversion from uchar[20] to struct object_id continues. * bc/object-id: (25 commits) refs/files-backend: convert static functions to object_id refs: convert read_raw_ref backends to struct object_id refs: convert peel_object to struct object_id refs: convert resolve_ref_unsafe to struct object_id worktree: convert struct worktree to object_id refs: convert resolve_gitlink_ref to struct object_id Convert remaining callers of resolve_gitlink_ref to object_id sha1_file: convert index_path and index_fd to struct object_id refs: convert reflog_expire parameter to struct object_id refs: convert read_ref_at to struct object_id refs: convert peel_ref to struct object_id builtin/pack-objects: convert to struct object_id pack-bitmap: convert traverse_bitmap_commit_list to object_id refs: convert dwim_log to struct object_id builtin/reflog: convert remaining unsigned char uses to object_id refs: convert dwim_ref and expand_ref to struct object_id refs: convert read_ref and read_ref_full to object_id refs: convert resolve_refdup and refs_resolve_refdup to struct object_id Convert check_connected to use struct object_id refs: update ref transactions to use struct object_id ...
2 parents 46c92e5 + 4f01e50 commit ef8aa26

Some content is hidden

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

70 files changed

+544
-554
lines changed

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void parse_treeish_arg(const char **argv,
371371
const char *colon = strchrnul(name, ':');
372372
int refnamelen = colon - name;
373373

374-
if (!dwim_ref(name, refnamelen, oid.hash, &ref))
374+
if (!dwim_ref(name, refnamelen, &oid, &ref))
375375
die("no such ref: %.*s", refnamelen, name);
376376
free(ref);
377377
}

bisect.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,12 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
690690
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
691691

692692
memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
693-
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
693+
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
694694

695695
argv_checkout[2] = bisect_rev_hex;
696696
if (no_checkout) {
697-
update_ref(NULL, "BISECT_HEAD", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
697+
update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
698+
UPDATE_REFS_DIE_ON_ERR);
698699
} else {
699700
int res;
700701
res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
166166
commit->date = now;
167167
parent_tail = &commit->parents;
168168

169-
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
169+
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
170170
die("no such ref: HEAD");
171171

172172
parent_tail = append_parent(parent_tail, &head_oid);
@@ -1689,7 +1689,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
16891689
return NULL;
16901690

16911691
/* Do we have HEAD? */
1692-
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
1692+
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
16931693
return NULL;
16941694
head_commit = lookup_commit_reference_gently(&head_oid, 1);
16951695
if (!head_commit)

branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void create_branch(const char *name, const char *start_name,
280280
die(_("Not a valid object name: '%s'."), start_name);
281281
}
282282

283-
switch (dwim_ref(start_name, strlen(start_name), oid.hash, &real_ref)) {
283+
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref)) {
284284
case 0:
285285
/* Not branching from any existing branch */
286286
if (explicit_tracking)
@@ -321,7 +321,7 @@ void create_branch(const char *name, const char *start_name,
321321
transaction = ref_transaction_begin(&err);
322322
if (!transaction ||
323323
ref_transaction_update(transaction, ref.buf,
324-
oid.hash, forcing ? NULL : null_sha1,
324+
&oid, forcing ? NULL : &null_oid,
325325
0, msg, &err) ||
326326
ref_transaction_commit(transaction, &err))
327327
die("%s", err.buf);

builtin/am.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
10681068
if (!get_oid("HEAD", &curr_head)) {
10691069
write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
10701070
if (!state->rebasing)
1071-
update_ref_oid("am", "ORIG_HEAD", &curr_head, NULL, 0,
1072-
UPDATE_REFS_DIE_ON_ERR);
1071+
update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
1072+
UPDATE_REFS_DIE_ON_ERR);
10731073
} else {
10741074
write_state_text(state, "abort-safety", "");
10751075
if (!state->rebasing)
@@ -1685,8 +1685,8 @@ static void do_commit(const struct am_state *state)
16851685
strbuf_addf(&sb, "%s: %.*s", reflog_msg, linelen(state->msg),
16861686
state->msg);
16871687

1688-
update_ref_oid(sb.buf, "HEAD", &commit, old_oid, 0,
1689-
UPDATE_REFS_DIE_ON_ERR);
1688+
update_ref(sb.buf, "HEAD", &commit, old_oid, 0,
1689+
UPDATE_REFS_DIE_ON_ERR);
16901690

16911691
if (state->rebasing) {
16921692
FILE *fp = xfopen(am_path(state, "rewritten"), "a");
@@ -2132,7 +2132,7 @@ static void am_abort(struct am_state *state)
21322132

21332133
am_rerere_clear();
21342134

2135-
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
2135+
curr_branch = resolve_refdup("HEAD", 0, &curr_head, NULL);
21362136
has_curr_head = curr_branch && !is_null_oid(&curr_head);
21372137
if (!has_curr_head)
21382138
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
@@ -2144,9 +2144,9 @@ static void am_abort(struct am_state *state)
21442144
clean_index(&curr_head, &orig_head);
21452145

21462146
if (has_orig_head)
2147-
update_ref_oid("am --abort", "HEAD", &orig_head,
2148-
has_curr_head ? &curr_head : NULL, 0,
2149-
UPDATE_REFS_DIE_ON_ERR);
2147+
update_ref("am --abort", "HEAD", &orig_head,
2148+
has_curr_head ? &curr_head : NULL, 0,
2149+
UPDATE_REFS_DIE_ON_ERR);
21502150
else if (curr_branch)
21512151
delete_ref(NULL, curr_branch, NULL, REF_NODEREF);
21522152

builtin/branch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int branch_merged(int kind, const char *name,
125125
if (upstream &&
126126
(reference_name = reference_name_to_free =
127127
resolve_refdup(upstream, RESOLVE_REF_READING,
128-
oid.hash, NULL)) != NULL)
128+
&oid, NULL)) != NULL)
129129
reference_rev = lookup_commit_reference(&oid);
130130
}
131131
if (!reference_rev)
@@ -241,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
241241
RESOLVE_REF_READING
242242
| RESOLVE_REF_NO_RECURSE
243243
| RESOLVE_REF_ALLOW_BAD_NAME,
244-
oid.hash, &flags);
244+
&oid, &flags);
245245
if (!target) {
246246
error(remote_branch
247247
? _("remote-tracking branch '%s' not found.")
@@ -257,7 +257,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
257257
goto next;
258258
}
259259

260-
if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : oid.hash,
260+
if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
261261
REF_NODEREF)) {
262262
error(remote_branch
263263
? _("Error deleting remote-tracking branch '%s'")
@@ -636,7 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
636636

637637
track = git_branch_track;
638638

639-
head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
639+
head = resolve_refdup("HEAD", 0, &head_oid, NULL);
640640
if (!head)
641641
die(_("Failed to resolve HEAD as a valid ref."));
642642
if (!strcmp(head, "HEAD"))

builtin/checkout.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static int checkout_paths(const struct checkout_opts *opts,
377377
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
378378
die(_("unable to write new index file"));
379379

380-
read_ref_full("HEAD", 0, rev.hash, NULL);
380+
read_ref_full("HEAD", 0, &rev, NULL);
381381
head = lookup_commit_reference_gently(&rev, 1);
382382

383383
errs |= post_checkout_hook(head, head, 0);
@@ -662,7 +662,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
662662
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
663663
/* Nothing to do. */
664664
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
665-
update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
665+
update_ref(msg.buf, "HEAD", &new->commit->object.oid, NULL,
666666
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
667667
if (!opts->quiet) {
668668
if (old->path &&
@@ -825,7 +825,7 @@ static int switch_branches(const struct checkout_opts *opts,
825825
struct object_id rev;
826826
int flag, writeout_error = 0;
827827
memset(&old, 0, sizeof(old));
828-
old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
828+
old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
829829
if (old.path)
830830
old.commit = lookup_commit_reference_gently(&rev, 1);
831831
if (!(flag & REF_ISSYMREF))
@@ -1036,7 +1036,7 @@ static int parse_branchname_arg(int argc, const char **argv,
10361036
setup_branch_path(new);
10371037

10381038
if (!check_refname_format(new->path, 0) &&
1039-
!read_ref(new->path, branch_rev.hash))
1039+
!read_ref(new->path, &branch_rev))
10401040
oidcpy(rev, &branch_rev);
10411041
else
10421042
new->path = NULL; /* not an existing branch */
@@ -1134,7 +1134,7 @@ static int checkout_branch(struct checkout_opts *opts,
11341134
struct object_id rev;
11351135
int flag;
11361136

1137-
if (!read_ref_full("HEAD", 0, rev.hash, &flag) &&
1137+
if (!read_ref_full("HEAD", 0, &rev, &flag) &&
11381138
(flag & REF_ISSYMREF) && is_null_oid(&rev))
11391139
return switch_unborn_to_new_branch(opts);
11401140
}

builtin/clone.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static void write_remote_refs(const struct ref *local_refs)
588588
for (r = local_refs; r; r = r->next) {
589589
if (!r->peer_ref)
590590
continue;
591-
if (ref_transaction_create(t, r->peer_ref->name, r->old_oid.hash,
591+
if (ref_transaction_create(t, r->peer_ref->name, &r->old_oid,
592592
0, NULL, &err))
593593
die("%s", err.buf);
594594
}
@@ -610,12 +610,12 @@ static void write_followtags(const struct ref *refs, const char *msg)
610610
continue;
611611
if (!has_object_file(&ref->old_oid))
612612
continue;
613-
update_ref(msg, ref->name, ref->old_oid.hash,
614-
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
613+
update_ref(msg, ref->name, &ref->old_oid, NULL, 0,
614+
UPDATE_REFS_DIE_ON_ERR);
615615
}
616616
}
617617

618-
static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
618+
static int iterate_ref_map(void *cb_data, struct object_id *oid)
619619
{
620620
struct ref **rm = cb_data;
621621
struct ref *ref = *rm;
@@ -630,7 +630,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
630630
if (!ref)
631631
return -1;
632632

633-
hashcpy(sha1, ref->old_oid.hash);
633+
oidcpy(oid, &ref->old_oid);
634634
*rm = ref->next;
635635
return 0;
636636
}
@@ -682,23 +682,23 @@ static void update_head(const struct ref *our, const struct ref *remote,
682682
if (create_symref("HEAD", our->name, NULL) < 0)
683683
die(_("unable to update HEAD"));
684684
if (!option_bare) {
685-
update_ref(msg, "HEAD", our->old_oid.hash, NULL, 0,
685+
update_ref(msg, "HEAD", &our->old_oid, NULL, 0,
686686
UPDATE_REFS_DIE_ON_ERR);
687687
install_branch_config(0, head, option_origin, our->name);
688688
}
689689
} else if (our) {
690690
struct commit *c = lookup_commit_reference(&our->old_oid);
691691
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
692-
update_ref(msg, "HEAD", c->object.oid.hash,
693-
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
692+
update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NODEREF,
693+
UPDATE_REFS_DIE_ON_ERR);
694694
} else if (remote) {
695695
/*
696696
* We know remote HEAD points to a non-branch, or
697697
* HEAD points to a branch but we don't know which one.
698698
* Detach HEAD in all these cases.
699699
*/
700-
update_ref(msg, "HEAD", remote->old_oid.hash,
701-
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
700+
update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NODEREF,
701+
UPDATE_REFS_DIE_ON_ERR);
702702
}
703703
}
704704

@@ -715,7 +715,7 @@ static int checkout(int submodule_progress)
715715
if (option_no_checkout)
716716
return 0;
717717

718-
head = resolve_refdup("HEAD", RESOLVE_REF_READING, oid.hash, NULL);
718+
head = resolve_refdup("HEAD", RESOLVE_REF_READING, &oid, NULL);
719719
if (!head) {
720720
warning(_("remote HEAD refers to nonexistent ref, "
721721
"unable to checkout.\n"));

builtin/commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,9 +1788,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17881788

17891789
transaction = ref_transaction_begin(&err);
17901790
if (!transaction ||
1791-
ref_transaction_update(transaction, "HEAD", oid.hash,
1791+
ref_transaction_update(transaction, "HEAD", &oid,
17921792
current_head
1793-
? current_head->object.oid.hash : null_sha1,
1793+
? &current_head->object.oid : &null_oid,
17941794
0, sb.buf, &err) ||
17951795
ref_transaction_commit(transaction, &err)) {
17961796
rollback_index_files();

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
181181
}
182182

183183
/* Is it annotated? */
184-
if (!peel_ref(path, peeled.hash)) {
184+
if (!peel_ref(path, &peeled)) {
185185
is_annotated = !!oidcmp(oid, &peeled);
186186
} else {
187187
oidcpy(&peeled, oid);

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
823823
if (e->flags & UNINTERESTING)
824824
continue;
825825

826-
if (dwim_ref(e->name, strlen(e->name), oid.hash, &full_name) != 1)
826+
if (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1)
827827
continue;
828828

829829
if (refspecs) {

builtin/fetch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ static int s_update_ref(const char *action,
457457
transaction = ref_transaction_begin(&err);
458458
if (!transaction ||
459459
ref_transaction_update(transaction, ref->name,
460-
ref->new_oid.hash,
461-
check_old ? ref->old_oid.hash : NULL,
460+
&ref->new_oid,
461+
check_old ? &ref->old_oid : NULL,
462462
0, msg, &err))
463463
goto fail;
464464

@@ -727,7 +727,7 @@ static int update_local_ref(struct ref *ref,
727727
}
728728
}
729729

730-
static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
730+
static int iterate_ref_map(void *cb_data, struct object_id *oid)
731731
{
732732
struct ref **rm = cb_data;
733733
struct ref *ref = *rm;
@@ -737,7 +737,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
737737
if (!ref)
738738
return -1; /* end of the list */
739739
*rm = ref->next;
740-
hashcpy(sha1, ref->old_oid.hash);
740+
oidcpy(oid, &ref->old_oid);
741741
return 0;
742742
}
743743

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
603603

604604
/* get current branch */
605605
current_branch = current_branch_to_free =
606-
resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
606+
resolve_refdup("HEAD", RESOLVE_REF_READING, &head_oid, NULL);
607607
if (!current_branch)
608608
die("No current branch");
609609
if (starts_with(current_branch, "refs/heads/"))

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ static int fsck_head_link(void)
555555
if (verbose)
556556
fprintf(stderr, "Checking HEAD link\n");
557557

558-
head_points_at = resolve_ref_unsafe("HEAD", 0, head_oid.hash, NULL);
558+
head_points_at = resolve_ref_unsafe("HEAD", 0, &head_oid, NULL);
559559
if (!head_points_at) {
560560
errors_found |= ERROR_REFS;
561561
return error("Invalid HEAD");

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ static char *find_branch_name(struct rev_info *rev)
975975
return NULL;
976976
ref = rev->cmdline.rev[positive].name;
977977
tip_oid = &rev->cmdline.rev[positive].item->oid;
978-
if (dwim_ref(ref, strlen(ref), branch_oid.hash, &full_ref) &&
978+
if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref) &&
979979
skip_prefix(full_ref, "refs/heads/", &v) &&
980980
!oidcmp(tip_oid, &branch_oid))
981981
branch = xstrdup(v);

builtin/merge-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int handle_fork_point(int argc, const char **argv)
156156
struct commit_list *bases;
157157
int i, ret = 0;
158158

159-
switch (dwim_ref(argv[0], strlen(argv[0]), oid.hash, &refname)) {
159+
switch (dwim_ref(argv[0], strlen(argv[0]), &oid, &refname)) {
160160
case 0:
161161
die("No such ref: '%s'", argv[0]);
162162
case 1:

0 commit comments

Comments
 (0)