Skip to content

Commit ff08e56

Browse files
committed
Merge branch 'bc/object-id' into base
2 parents 2f89985 + 4f01e50 commit ff08e56

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
@@ -685,11 +685,12 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
685685
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
686686

687687
memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
688-
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
688+
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
689689

690690
argv_checkout[2] = bisect_rev_hex;
691691
if (no_checkout) {
692-
update_ref(NULL, "BISECT_HEAD", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
692+
update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
693+
UPDATE_REFS_DIE_ON_ERR);
693694
} else {
694695
int res;
695696
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
@@ -264,7 +264,7 @@ void create_branch(const char *name, const char *start_name,
264264
die(_("Not a valid object name: '%s'."), start_name);
265265
}
266266

267-
switch (dwim_ref(start_name, strlen(start_name), oid.hash, &real_ref)) {
267+
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref)) {
268268
case 0:
269269
/* Not branching from any existing branch */
270270
if (explicit_tracking)
@@ -305,7 +305,7 @@ void create_branch(const char *name, const char *start_name,
305305
transaction = ref_transaction_begin(&err);
306306
if (!transaction ||
307307
ref_transaction_update(transaction, ref.buf,
308-
oid.hash, forcing ? NULL : null_sha1,
308+
&oid, forcing ? NULL : &null_oid,
309309
0, msg, &err) ||
310310
ref_transaction_commit(transaction, &err))
311311
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)
@@ -1686,8 +1686,8 @@ static void do_commit(const struct am_state *state)
16861686
strbuf_addf(&sb, "%s: %.*s", reflog_msg, linelen(state->msg),
16871687
state->msg);
16881688

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

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

21362136
am_rerere_clear();
21372137

2138-
curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
2138+
curr_branch = resolve_refdup("HEAD", 0, &curr_head, NULL);
21392139
has_curr_head = curr_branch && !is_null_oid(&curr_head);
21402140
if (!has_curr_head)
21412141
hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
@@ -2147,9 +2147,9 @@ static void am_abort(struct am_state *state)
21472147
clean_index(&curr_head, &orig_head);
21482148

21492149
if (has_orig_head)
2150-
update_ref_oid("am --abort", "HEAD", &orig_head,
2151-
has_curr_head ? &curr_head : NULL, 0,
2152-
UPDATE_REFS_DIE_ON_ERR);
2150+
update_ref("am --abort", "HEAD", &orig_head,
2151+
has_curr_head ? &curr_head : NULL, 0,
2152+
UPDATE_REFS_DIE_ON_ERR);
21532153
else if (curr_branch)
21542154
delete_ref(NULL, curr_branch, NULL, REF_NODEREF);
21552155

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
@@ -379,7 +379,7 @@ static int checkout_paths(const struct checkout_opts *opts,
379379
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
380380
die(_("unable to write new index file"));
381381

382-
read_ref_full("HEAD", 0, rev.hash, NULL);
382+
read_ref_full("HEAD", 0, &rev, NULL);
383383
head = lookup_commit_reference_gently(&rev, 1);
384384

385385
errs |= post_checkout_hook(head, head, 0);
@@ -664,7 +664,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
664664
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
665665
/* Nothing to do. */
666666
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
667-
update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
667+
update_ref(msg.buf, "HEAD", &new->commit->object.oid, NULL,
668668
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
669669
if (!opts->quiet) {
670670
if (old->path &&
@@ -827,7 +827,7 @@ static int switch_branches(const struct checkout_opts *opts,
827827
struct object_id rev;
828828
int flag, writeout_error = 0;
829829
memset(&old, 0, sizeof(old));
830-
old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
830+
old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
831831
if (old.path)
832832
old.commit = lookup_commit_reference_gently(&rev, 1);
833833
if (!(flag & REF_ISSYMREF))
@@ -1038,7 +1038,7 @@ static int parse_branchname_arg(int argc, const char **argv,
10381038
setup_branch_path(new);
10391039

10401040
if (!check_refname_format(new->path, 0) &&
1041-
!read_ref(new->path, branch_rev.hash))
1041+
!read_ref(new->path, &branch_rev))
10421042
oidcpy(rev, &branch_rev);
10431043
else
10441044
new->path = NULL; /* not an existing branch */
@@ -1136,7 +1136,7 @@ static int checkout_branch(struct checkout_opts *opts,
11361136
struct object_id rev;
11371137
int flag;
11381138

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

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);

0 commit comments

Comments
 (0)