Convert struct ref to use object_id.

Use struct object_id in three fields in struct ref and convert all the necessary places that use it. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>

brian m. carlson committed Nov 10, 2015 at 02:22 UTC f4e54d02b894064d370e461385b48701485672bd
18 files changed +151 -151
builtin/clone.c
+8 -8
@@ -559,7 +559,7 @@ static void write_remote_refs(const struct ref *local_refs)
559 for (r = local_refs; r; r = r->next) {
560 if (!r->peer_ref)
561 continue;
562 - if (ref_transaction_create(t, r->peer_ref->name, r->old_sha1,
562 + if (ref_transaction_create(t, r->peer_ref->name, r->old_oid.hash,
563 0, NULL, &err))
564 die("%s", err.buf);
565 }
@@ -579,9 +579,9 @@ static void write_followtags(const struct ref *refs, const char *msg)
579 continue;
580 if (ends_with(ref->name, "^{}"))
581 continue;
582 - if (!has_sha1_file(ref->old_sha1))
582 + if (!has_object_file(&ref->old_oid))
583 continue;
584 - update_ref(msg, ref->name, ref->old_sha1,
584 + update_ref(msg, ref->name, ref->old_oid.hash,
585 NULL, 0, UPDATE_REFS_DIE_ON_ERR);
586 }
587 }
@@ -601,7 +601,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
601 if (!ref)
602 return -1;
603
604 - hashcpy(sha1, ref->old_sha1);
604 + hashcpy(sha1, ref->old_oid.hash);
605 *rm = ref->next;
606 return 0;
607 }
@@ -650,12 +650,12 @@ static void update_head(const struct ref *our, const struct ref *remote,
650 /* Local default branch link */
651 create_symref("HEAD", our->name, NULL);
652 if (!option_bare) {
653 - update_ref(msg, "HEAD", our->old_sha1, NULL, 0,
653 + update_ref(msg, "HEAD", our->old_oid.hash, NULL, 0,
654 UPDATE_REFS_DIE_ON_ERR);
655 install_branch_config(0, head, option_origin, our->name);
656 }
657 } else if (our) {
658 - struct commit *c = lookup_commit_reference(our->old_sha1);
658 + struct commit *c = lookup_commit_reference(our->old_oid.hash);
659 /* --branch specifies a non-branch (i.e. tags), detach HEAD */
660 update_ref(msg, "HEAD", c->object.sha1,
661 NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
@@ -665,7 +665,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
665 * HEAD points to a branch but we don't know which one.
666 * Detach HEAD in all these cases.
667 */
668 - update_ref(msg, "HEAD", remote->old_sha1,
668 + update_ref(msg, "HEAD", remote->old_oid.hash,
669 NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
670 }
671 }
@@ -1016,7 +1016,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1016 * remote HEAD check.
1017 */
1018 for (ref = refs; ref; ref = ref->next)
1019 - if (is_null_sha1(ref->old_sha1)) {
1019 + if (is_null_oid(&ref->old_oid)) {
1020 complete_refs_before_fetch = 0;
1021 break;
1022 }
builtin/fetch-pack.c
+2 -2
@@ -17,7 +17,7 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,
17 unsigned char sha1[20];
18
19 if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
20 - hashcpy(ref->old_sha1, sha1);
20 + hashcpy(ref->old_oid.hash, sha1);
21 name += 41;
22 namelen -= 41;
23 }
@@ -210,7 +210,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
210
211 while (ref) {
212 printf("%s %s\n",
213 - sha1_to_hex(ref->old_sha1), ref->name);
213 + oid_to_hex(&ref->old_oid), ref->name);
214 ref = ref->next;
215 }
216
builtin/fetch.c
+25 -25
@@ -196,7 +196,7 @@ static int will_fetch(struct ref **head, const unsigned char *sha1)
196 {
197 struct ref *rm = *head;
198 while (rm) {
199 - if (!hashcmp(rm->old_sha1, sha1))
199 + if (!hashcmp(rm->old_oid.hash, sha1))
200 return 1;
201 rm = rm->next;
202 }
@@ -224,8 +224,8 @@ static void find_non_local_tags(struct transport *transport,
224 * as one to ignore by setting util to NULL.
225 */
226 if (ends_with(ref->name, "^{}")) {
227 - if (item && !has_sha1_file(ref->old_sha1) &&
228 - !will_fetch(head, ref->old_sha1) &&
227 + if (item && !has_object_file(&ref->old_oid) &&
228 + !will_fetch(head, ref->old_oid.hash) &&
229 !has_sha1_file(item->util) &&
230 !will_fetch(head, item->util))
231 item->util = NULL;
@@ -251,7 +251,7 @@ static void find_non_local_tags(struct transport *transport,
251 continue;
252
253 item = string_list_insert(&remote_refs, ref->name);
254 - item->util = (void *)ref->old_sha1;
254 + item->util = (void *)&ref->old_oid;
255 }
256 string_list_clear(&existing_refs, 1);
257
@@ -273,7 +273,7 @@ static void find_non_local_tags(struct transport *transport,
273 {
274 struct ref *rm = alloc_ref(item->string);
275 rm->peer_ref = alloc_ref(item->string);
276 - hashcpy(rm->old_sha1, item->util);
276 + oidcpy(&rm->old_oid, item->util);
277 **tail = rm;
278 *tail = &rm->next;
279 }
@@ -419,8 +419,8 @@ static int s_update_ref(const char *action,
419 transaction = ref_transaction_begin(&err);
420 if (!transaction ||
421 ref_transaction_update(transaction, ref->name,
422 - ref->new_sha1,
423 - check_old ? ref->old_sha1 : NULL,
422 + ref->new_oid.hash,
423 + check_old ? ref->old_oid.hash : NULL,
424 0, msg, &err))
425 goto fail;
426
@@ -453,11 +453,11 @@ static int update_local_ref(struct ref *ref,
453 struct branch *current_branch = branch_get(NULL);
454 const char *pretty_ref = prettify_refname(ref->name);
455
456 - type = sha1_object_info(ref->new_sha1, NULL);
456 + type = sha1_object_info(ref->new_oid.hash, NULL);
457 if (type < 0)
458 - die(_("object %s not found"), sha1_to_hex(ref->new_sha1));
458 + die(_("object %s not found"), oid_to_hex(&ref->new_oid));
459
460 - if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
460 + if (!oidcmp(&ref->old_oid, &ref->new_oid)) {
461 if (verbosity > 0)
462 strbuf_addf(display, "= %-*s %-*s -> %s",
463 TRANSPORT_SUMMARY(_("[up to date]")),
@@ -468,7 +468,7 @@ static int update_local_ref(struct ref *ref,
468 if (current_branch &&
469 !strcmp(ref->name, current_branch->name) &&
470 !(update_head_ok || is_bare_repository()) &&
471 - !is_null_sha1(ref->old_sha1)) {
471 + !is_null_oid(&ref->old_oid)) {
472 /*
473 * If this is the head, and it's not okay to update
474 * the head, and the old value of the head isn't empty...
@@ -480,7 +480,7 @@ static int update_local_ref(struct ref *ref,
480 return 1;
481 }
482
483 - if (!is_null_sha1(ref->old_sha1) &&
483 + if (!is_null_oid(&ref->old_oid) &&
484 starts_with(ref->name, "refs/tags/")) {
485 int r;
486 r = s_update_ref("updating tag", ref, 0);
@@ -492,8 +492,8 @@ static int update_local_ref(struct ref *ref,
492 return r;
493 }
494
495 - current = lookup_commit_reference_gently(ref->old_sha1, 1);
496 - updated = lookup_commit_reference_gently(ref->new_sha1, 1);
495 + current = lookup_commit_reference_gently(ref->old_oid.hash, 1);
496 + updated = lookup_commit_reference_gently(ref->new_oid.hash, 1);
497 if (!current || !updated) {
498 const char *msg;
499 const char *what;
@@ -517,7 +517,7 @@ static int update_local_ref(struct ref *ref,
517
518 if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
519 (recurse_submodules != RECURSE_SUBMODULES_ON))
520 - check_for_new_submodule_commits(ref->new_sha1);
520 + check_for_new_submodule_commits(ref->new_oid.hash);
521 r = s_update_ref(msg, ref, 0);
522 strbuf_addf(display, "%c %-*s %-*s -> %s%s",
523 r ? '!' : '*',
@@ -532,10 +532,10 @@ static int update_local_ref(struct ref *ref,
532 int r;
533 strbuf_add_unique_abbrev(&quickref, current->object.sha1, DEFAULT_ABBREV);
534 strbuf_addstr(&quickref, "..");
535 - strbuf_add_unique_abbrev(&quickref, ref->new_sha1, DEFAULT_ABBREV);
535 + strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
536 if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
537 (recurse_submodules != RECURSE_SUBMODULES_ON))
538 - check_for_new_submodule_commits(ref->new_sha1);
538 + check_for_new_submodule_commits(ref->new_oid.hash);
539 r = s_update_ref("fast-forward", ref, 1);
540 strbuf_addf(display, "%c %-*s %-*s -> %s%s",
541 r ? '!' : ' ',
@@ -549,10 +549,10 @@ static int update_local_ref(struct ref *ref,
549 int r;
550 strbuf_add_unique_abbrev(&quickref, current->object.sha1, DEFAULT_ABBREV);
551 strbuf_addstr(&quickref, "...");
552 - strbuf_add_unique_abbrev(&quickref, ref->new_sha1, DEFAULT_ABBREV);
552 + strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
553 if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
554 (recurse_submodules != RECURSE_SUBMODULES_ON))
555 - check_for_new_submodule_commits(ref->new_sha1);
555 + check_for_new_submodule_commits(ref->new_oid.hash);
556 r = s_update_ref("forced-update", ref, 1);
557 strbuf_addf(display, "%c %-*s %-*s -> %s (%s)",
558 r ? '!' : '+',
@@ -580,7 +580,7 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
580 if (!ref)
581 return -1; /* end of the list */
582 *rm = ref->next;
583 - hashcpy(sha1, ref->old_sha1);
583 + hashcpy(sha1, ref->old_oid.hash);
584 return 0;
585 }
586
@@ -631,7 +631,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
631 continue;
632 }
633
634 - commit = lookup_commit_reference_gently(rm->old_sha1, 1);
634 + commit = lookup_commit_reference_gently(rm->old_oid.hash, 1);
635 if (!commit)
636 rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;
637
@@ -640,8 +640,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
640
641 if (rm->peer_ref) {
642 ref = alloc_ref(rm->peer_ref->name);
643 - hashcpy(ref->old_sha1, rm->peer_ref->old_sha1);
644 - hashcpy(ref->new_sha1, rm->old_sha1);
643 + oidcpy(&ref->old_oid, &rm->peer_ref->old_oid);
644 + oidcpy(&ref->new_oid, &rm->old_oid);
645 ref->force = rm->peer_ref->force;
646 }
647
@@ -686,7 +686,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
686 /* fall-through */
687 case FETCH_HEAD_MERGE:
688 fprintf(fp, "%s\t%s\t%s",
689 - sha1_to_hex(rm->old_sha1),
689 + oid_to_hex(&rm->old_oid),
690 merge_status_marker,
691 note.buf);
692 for (i = 0; i < url_len; ++i)
@@ -928,7 +928,7 @@ static int do_fetch(struct transport *transport,
928 rm->peer_ref->name);
929 if (peer_item) {
930 struct object_id *old_oid = peer_item->util;
931 - hashcpy(rm->peer_ref->old_sha1, old_oid->hash);
931 + oidcpy(&rm->peer_ref->old_oid, old_oid);
932 }
933 }
934 }
builtin/ls-remote.c
+1 -1
@@ -125,7 +125,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
125 continue;
126 if (!tail_match(pattern, ref->name))
127 continue;
128 - printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name);
128 + printf("%s %s\n", oid_to_hex(&ref->old_oid), ref->name);
129 status = 0; /* we found something */
130 }
131 return status;
builtin/receive-pack.c
+1 -1
@@ -246,7 +246,7 @@ static void show_one_alternate_sha1(const unsigned char sha1[20], void *unused)
246 static void collect_one_alternate_ref(const struct ref *ref, void *data)
247 {
248 struct sha1_array *sa = data;
249 - sha1_array_append(sa, ref->old_sha1);
249 + sha1_array_append(sa, ref->old_oid.hash);
250 }
251
252 static void write_head_info(void)
builtin/remote.c
+6 -6
@@ -401,7 +401,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
401
402 if (!ref->peer_ref)
403 continue;
404 - hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
404 + oidcpy(&ref->new_oid, &ref->peer_ref->new_oid);
405
406 item = string_list_append(&states->push,
407 abbrev_branch(ref->peer_ref->name));
@@ -410,14 +410,14 @@ static int get_push_ref_states(const struct ref *remote_refs,
410 info->forced = ref->force;
411 info->dest = xstrdup(abbrev_branch(ref->name));
412
413 - if (is_null_sha1(ref->new_sha1)) {
413 + if (is_null_oid(&ref->new_oid)) {
414 info->status = PUSH_STATUS_DELETE;
415 - } else if (!hashcmp(ref->old_sha1, ref->new_sha1))
415 + } else if (!oidcmp(&ref->old_oid, &ref->new_oid))
416 info->status = PUSH_STATUS_UPTODATE;
417 - else if (is_null_sha1(ref->old_sha1))
417 + else if (is_null_oid(&ref->old_oid))
418 info->status = PUSH_STATUS_CREATE;
419 - else if (has_sha1_file(ref->old_sha1) &&
420 - ref_newer(ref->new_sha1, ref->old_sha1))
419 + else if (has_object_file(&ref->old_oid) &&
420 + ref_newer(ref->new_oid.hash, ref->old_oid.hash))
421 info->status = PUSH_STATUS_FASTFORWARD;
422 else
423 info->status = PUSH_STATUS_OUTOFDATE;
connect.c
+1 -1
@@ -166,7 +166,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
166 if (!check_ref(name, flags))
167 continue;
168 ref = alloc_ref(buffer + 41);
169 - hashcpy(ref->old_sha1, old_sha1);
169 + hashcpy(ref->old_oid.hash, old_sha1);
170 *list = ref;
171 list = &ref->next;
172 got_at_least_one_head = 1;
fetch-pack.c
+9 -9
@@ -238,7 +238,7 @@ static void send_request(struct fetch_pack_args *args,
238
239 static void insert_one_alternate_ref(const struct ref *ref, void *unused)
240 {
241 - rev_list_insert_ref(NULL, ref->old_sha1);
241 + rev_list_insert_ref(NULL, ref->old_oid.hash);
242 }
243
244 #define INITIAL_FLUSH 16
@@ -280,7 +280,7 @@ static int find_common(struct fetch_pack_args *args,
280
281 fetching = 0;
282 for ( ; refs ; refs = refs->next) {
283 - unsigned char *remote = refs->old_sha1;
283 + unsigned char *remote = refs->old_oid.hash;
284 const char *remote_hex;
285 struct object *o;
286
@@ -570,7 +570,7 @@ static void filter_refs(struct fetch_pack_args *args,
570 continue;
571 if (get_sha1_hex(ref->name, sha1) ||
572 ref->name[40] != '\0' ||
573 - hashcmp(sha1, ref->old_sha1))
573 + hashcmp(sha1, ref->old_oid.hash))
574 continue;
575
576 ref->matched = 1;
@@ -583,7 +583,7 @@ static void filter_refs(struct fetch_pack_args *args,
583
584 static void mark_alternate_complete(const struct ref *ref, void *unused)
585 {
586 - mark_complete(ref->old_sha1);
586 + mark_complete(ref->old_oid.hash);
587 }
588
589 static int everything_local(struct fetch_pack_args *args,
@@ -599,10 +599,10 @@ static int everything_local(struct fetch_pack_args *args,
599 for (ref = *refs; ref; ref = ref->next) {
600 struct object *o;
601
602 - if (!has_sha1_file(ref->old_sha1))
602 + if (!has_object_file(&ref->old_oid))
603 continue;
604
605 - o = parse_object(ref->old_sha1);
605 + o = parse_object(ref->old_oid.hash);
606 if (!o)
607 continue;
608
@@ -630,7 +630,7 @@ static int everything_local(struct fetch_pack_args *args,
630 * Don't mark them common yet; the server has to be told so first.
631 */
632 for (ref = *refs; ref; ref = ref->next) {
633 - struct object *o = deref_tag(lookup_object(ref->old_sha1),
633 + struct object *o = deref_tag(lookup_object(ref->old_oid.hash),
634 NULL, 0);
635
636 if (!o || o->type != OBJ_COMMIT || !(o->flags & COMPLETE))
@@ -646,7 +646,7 @@ static int everything_local(struct fetch_pack_args *args,
646 filter_refs(args, refs, sought, nr_sought);
647
648 for (retval = 1, ref = *refs; ref ; ref = ref->next) {
649 - const unsigned char *remote = ref->old_sha1;
649 + const unsigned char *remote = ref->old_oid.hash;
650 struct object *o;
651
652 o = lookup_object(remote);
@@ -985,7 +985,7 @@ static void update_shallow(struct fetch_pack_args *args,
985 if (!si->nr_ours && !si->nr_theirs)
986 return;
987 for (i = 0; i < nr_sought; i++)
988 - sha1_array_append(&ref, sought[i]->old_sha1);
988 + sha1_array_append(&ref, sought[i]->old_oid.hash);
989 si->ref = &ref;
990
991 if (args->update_shallow) {
http-push.c
+22 -22
@@ -1438,11 +1438,11 @@ static void one_remote_ref(const char *refname)
1438 * Fetch a copy of the object if it doesn't exist locally - it
1439 * may be required for updating server info later.
1440 */
1441 - if (repo->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {
1442 - obj = lookup_unknown_object(ref->old_sha1);
1441 + if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
1442 + obj = lookup_unknown_object(ref->old_oid.hash);
1443 if (obj) {
1444 fprintf(stderr, " fetch %s for %s\n",
1445 - sha1_to_hex(ref->old_sha1), refname);
1445 + oid_to_hex(&ref->old_oid), refname);
1446 add_fetch_request(obj);
1447 }
1448 }
@@ -1473,18 +1473,18 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
1473 return;
1474 }
1475
1476 - o = parse_object(ref->old_sha1);
1476 + o = parse_object(ref->old_oid.hash);
1477 if (!o) {
1478 fprintf(stderr,
1479 "Unable to parse object %s for remote ref %s\n",
1480 - sha1_to_hex(ref->old_sha1), ls->dentry_name);
1480 + oid_to_hex(&ref->old_oid), ls->dentry_name);
1481 aborted = 1;
1482 free(ref);
1483 return;
1484 }
1485
1486 strbuf_addf(buf, "%s\t%s\n",
1487 - sha1_to_hex(ref->old_sha1), ls->dentry_name);
1487 + oid_to_hex(&ref->old_oid), ls->dentry_name);
1488
1489 if (o->type == OBJ_TAG) {
1490 o = deref_tag(o, ls->dentry_name, 0);
@@ -1581,7 +1581,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
1581 static int verify_merge_base(unsigned char *head_sha1, struct ref *remote)
1582 {
1583 struct commit *head = lookup_commit_or_die(head_sha1, "HEAD");
1584 - struct commit *branch = lookup_commit_or_die(remote->old_sha1, remote->name);
1584 + struct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);
1585
1586 return in_merge_bases(branch, head);
1587 }
@@ -1644,11 +1644,11 @@ static int delete_remote_branch(const char *pattern, int force)
1644 return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", sha1_to_hex(head_sha1));
1645
1646 /* Remote branch must resolve to a known object */
1647 - if (is_null_sha1(remote_ref->old_sha1))
1647 + if (is_null_oid(&remote_ref->old_oid))
1648 return error("Unable to resolve remote branch %s",
1649 remote_ref->name);
1650 - if (!has_sha1_file(remote_ref->old_sha1))
1651 - return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, sha1_to_hex(remote_ref->old_sha1));
1650 + if (!has_object_file(&remote_ref->old_oid))
1651 + return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
1652
1653 /* Remote branch must be an ancestor of remote HEAD */
1654 if (!verify_merge_base(head_sha1, remote_ref)) {
@@ -1861,7 +1861,7 @@ int main(int argc, char **argv)
1861 if (!ref->peer_ref)
1862 continue;
1863
1864 - if (is_null_sha1(ref->peer_ref->new_sha1)) {
1864 + if (is_null_oid(&ref->peer_ref->new_oid)) {
1865 if (delete_remote_branch(ref->name, 1) == -1) {
1866 error("Could not remove %s", ref->name);
1867 if (helper_status)
@@ -1874,7 +1874,7 @@ int main(int argc, char **argv)
1874 continue;
1875 }
1876
1877 - if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
1877 + if (!oidcmp(&ref->old_oid, &ref->peer_ref->new_oid)) {
1878 if (push_verbosely)
1879 fprintf(stderr, "'%s': up-to-date\n", ref->name);
1880 if (helper_status)
@@ -1883,11 +1883,11 @@ int main(int argc, char **argv)
1883 }
1884
1885 if (!force_all &&
1886 - !is_null_sha1(ref->old_sha1) &&
1886 + !is_null_oid(&ref->old_oid) &&
1887 !ref->force) {
1888 - if (!has_sha1_file(ref->old_sha1) ||
1889 - !ref_newer(ref->peer_ref->new_sha1,
1890 - ref->old_sha1)) {
1888 + if (!has_object_file(&ref->old_oid) ||
1889 + !ref_newer(ref->peer_ref->new_oid.hash,
1890 + ref->old_oid.hash)) {
1891 /*
1892 * We do not have the remote ref, or
1893 * we know that the remote ref is not
@@ -1908,14 +1908,14 @@ int main(int argc, char **argv)
1908 continue;
1909 }
1910 }
1911 - hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
1911 + oidcpy(&ref->new_oid, &ref->peer_ref->new_oid);
1912 new_refs++;
1913
1914 fprintf(stderr, "updating '%s'", ref->name);
1915 if (strcmp(ref->name, ref->peer_ref->name))
1916 fprintf(stderr, " using '%s'", ref->peer_ref->name);
1917 fprintf(stderr, "\n from %s\n to %s\n",
1918 - sha1_to_hex(ref->old_sha1), sha1_to_hex(ref->new_sha1));
1918 + oid_to_hex(&ref->old_oid), oid_to_hex(&ref->new_oid));
1919 if (dry_run) {
1920 if (helper_status)
1921 printf("ok %s\n", ref->name);
@@ -1936,10 +1936,10 @@ int main(int argc, char **argv)
1936 /* Set up revision info for this refspec */
1937 argv_array_push(&commit_argv, ""); /* ignored */
1938 argv_array_push(&commit_argv, "--objects");
1939 - argv_array_push(&commit_argv, sha1_to_hex(ref->new_sha1));
1940 - if (!push_all && !is_null_sha1(ref->old_sha1))
1939 + argv_array_push(&commit_argv, oid_to_hex(&ref->new_oid));
1940 + if (!push_all && !is_null_oid(&ref->old_oid))
1941 argv_array_pushf(&commit_argv, "^%s",
1942 - sha1_to_hex(ref->old_sha1));
1942 + oid_to_hex(&ref->old_oid));
1943 init_revisions(&revs, setup_git_directory());
1944 setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL);
1945 revs.edge_hint = 0; /* just in case */
@@ -1962,7 +1962,7 @@ int main(int argc, char **argv)
1962 run_request_queue();
1963
1964 /* Update the remote branch if all went well */
1965 - if (aborted || !update_remote(ref->new_sha1, ref_lock))
1965 + if (aborted || !update_remote(ref->new_oid.hash, ref_lock))
1966 rc = 1;
1967
1968 if (!rc)
http.c
+1 -1
@@ -1391,7 +1391,7 @@ int http_fetch_ref(const char *base, struct ref *ref)
1391 if (http_get_strbuf(url, &buffer, &options) == HTTP_OK) {
1392 strbuf_rtrim(&buffer);
1393 if (buffer.len == 40)
1394 - ret = get_sha1_hex(buffer.buf, ref->old_sha1);
1394 + ret = get_oid_hex(buffer.buf, &ref->old_oid);
1395 else if (starts_with(buffer.buf, "ref: ")) {
1396 ref->symref = xstrdup(buffer.buf + 5);
1397 ret = 0;
remote-curl.c
+5 -5
@@ -169,7 +169,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
169 data[i] = 0;
170 ref_name = mid + 1;
171 ref = alloc_ref(ref_name);
172 - get_sha1_hex(start, ref->old_sha1);
172 + get_oid_hex(start, &ref->old_oid);
173 if (!refs)
174 refs = ref;
175 if (last_ref)
@@ -348,7 +348,7 @@ static void output_refs(struct ref *refs)
348 if (posn->symref)
349 printf("@%s %s\n", posn->symref, posn->name);
350 else
351 - printf("%s %s\n", sha1_to_hex(posn->old_sha1), posn->name);
351 + printf("%s %s\n", oid_to_hex(&posn->old_oid), posn->name);
352 }
353 printf("\n");
354 fflush(stdout);
@@ -702,7 +702,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
702 if (options.depth)
703 die("dumb http transport does not support --depth");
704 for (i = 0; i < nr_heads; i++)
705 - targets[i] = xstrdup(sha1_to_hex(to_fetch[i]->old_sha1));
705 + targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));
706
707 walker = get_http_walker(url.buf);
708 walker->get_all = 1;
@@ -763,7 +763,7 @@ static int fetch_git(struct discovery *heads,
763 if (!*ref->name)
764 die("cannot fetch by sha1 over smart http");
765 packet_buf_write(&preamble, "%s %s\n",
766 - sha1_to_hex(ref->old_sha1), ref->name);
766 + oid_to_hex(&ref->old_oid), ref->name);
767 }
768 packet_buf_flush(&preamble);
769
@@ -815,7 +815,7 @@ static void parse_fetch(struct strbuf *buf)
815 die("protocol error: expected sha/ref, got %s'", p);
816
817 ref = alloc_ref(name);
818 - hashcpy(ref->old_sha1, old_sha1);
818 + hashcpy(ref->old_oid.hash, old_sha1);
819
820 *list = ref;
821 list = &ref->next;
remote.c
+29 -29
@@ -1075,7 +1075,7 @@ static void tail_link_ref(struct ref *ref, struct ref ***tail)
1075 static struct ref *alloc_delete_ref(void)
1076 {
1077 struct ref *ref = alloc_ref("(delete)");
1078 - hashclr(ref->new_sha1);
1078 + oidclr(&ref->new_oid);
1079 return ref;
1080 }
1081
@@ -1095,7 +1095,7 @@ static int try_explicit_object_name(const char *name,
1095
1096 if (match) {
1097 *match = alloc_ref(name);
1098 - hashcpy((*match)->new_sha1, sha1);
1098 + hashcpy((*match)->new_oid.hash, sha1);
1099 }
1100 return 0;
1101 }
@@ -1190,7 +1190,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
1190 case 0:
1191 if (starts_with(dst_value, "refs/"))
1192 matched_dst = make_linked_ref(dst_value, dst_tail);
1193 - else if (is_null_sha1(matched_src->new_sha1))
1193 + else if (is_null_oid(&matched_src->new_oid))
1194 error("unable to delete '%s': remote ref does not exist",
1195 dst_value);
1196 else if ((dst_guess = guess_ref(dst_value, matched_src)))
@@ -1321,10 +1321,10 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1321 memset(&sent_tips, 0, sizeof(sent_tips));
1322 for (ref = *dst; ref; ref = ref->next) {
1323 if (ref->peer_ref &&
1324 - !is_null_sha1(ref->peer_ref->new_sha1))
1325 - add_to_tips(&sent_tips, ref->peer_ref->new_sha1);
1324 + !is_null_oid(&ref->peer_ref->new_oid))
1325 + add_to_tips(&sent_tips, ref->peer_ref->new_oid.hash);
1326 else
1327 - add_to_tips(&sent_tips, ref->old_sha1);
1327 + add_to_tips(&sent_tips, ref->old_oid.hash);
1328 if (starts_with(ref->name, "refs/tags/"))
1329 string_list_append(&dst_tag, ref->name);
1330 }
@@ -1338,7 +1338,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1338 continue; /* not a tag */
1339 if (string_list_has_string(&dst_tag, ref->name))
1340 continue; /* they already have it */
1341 - if (sha1_object_info(ref->new_sha1, NULL) != OBJ_TAG)
1341 + if (sha1_object_info(ref->new_oid.hash, NULL) != OBJ_TAG)
1342 continue; /* be conservative */
1343 item = string_list_append(&src_tag, ref->name);
1344 item->util = ref;
@@ -1358,9 +1358,9 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1358 struct ref *dst_ref;
1359 struct commit *commit;
1360
1361 - if (is_null_sha1(ref->new_sha1))
1361 + if (is_null_oid(&ref->new_oid))
1362 continue;
1363 - commit = lookup_commit_reference_gently(ref->new_sha1, 1);
1363 + commit = lookup_commit_reference_gently(ref->new_oid.hash, 1);
1364 if (!commit)
1365 /* not pushing a commit, which is not an error */
1366 continue;
@@ -1374,7 +1374,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1374
1375 /* Add it in */
1376 dst_ref = make_linked_ref(ref->name, dst_tail);
1377 - hashcpy(dst_ref->new_sha1, ref->new_sha1);
1377 + oidcpy(&dst_ref->new_oid, &ref->new_oid);
1378 dst_ref->peer_ref = copy_ref(ref);
1379 }
1380 }
@@ -1481,7 +1481,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
1481
1482 /* Create a new one and link it */
1483 dst_peer = make_linked_ref(dst_name, &dst_tail);
1484 - hashcpy(dst_peer->new_sha1, ref->new_sha1);
1484 + oidcpy(&dst_peer->new_oid, &ref->new_oid);
1485 string_list_insert(&dst_ref_index,
1486 dst_peer->name)->util = dst_peer;
1487 }
@@ -1533,13 +1533,13 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1533 int reject_reason = 0;
1534
1535 if (ref->peer_ref)
1536 - hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
1536 + oidcpy(&ref->new_oid, &ref->peer_ref->new_oid);
1537 else if (!send_mirror)
1538 continue;
1539
1540 - ref->deletion = is_null_sha1(ref->new_sha1);
1540 + ref->deletion = is_null_oid(&ref->new_oid);
1541 if (!ref->deletion &&
1542 - !hashcmp(ref->old_sha1, ref->new_sha1)) {
1542 + !oidcmp(&ref->old_oid, &ref->new_oid)) {
1543 ref->status = REF_STATUS_UPTODATE;
1544 continue;
1545 }
@@ -1558,7 +1558,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1558 */
1559 if (ref->expect_old_sha1) {
1560 if (ref->expect_old_no_trackback ||
1561 - hashcmp(ref->old_sha1, ref->old_sha1_expect))
1561 + oidcmp(&ref->old_oid, &ref->old_oid_expect))
1562 reject_reason = REF_STATUS_REJECT_STALE;
1563 }
1564
@@ -1582,15 +1582,15 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1582 * passing the --force argument
1583 */
1584
1585 - else if (!ref->deletion && !is_null_sha1(ref->old_sha1)) {
1585 + else if (!ref->deletion && !is_null_oid(&ref->old_oid)) {
1586 if (starts_with(ref->name, "refs/tags/"))
1587 reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
1588 - else if (!has_sha1_file(ref->old_sha1))
1588 + else if (!has_object_file(&ref->old_oid))
1589 reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
1590 - else if (!lookup_commit_reference_gently(ref->old_sha1, 1) ||
1591 - !lookup_commit_reference_gently(ref->new_sha1, 1))
1590 + else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
1591 + !lookup_commit_reference_gently(ref->new_oid.hash, 1))
1592 reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
1593 - else if (!ref_newer(ref->new_sha1, ref->old_sha1))
1593 + else if (!ref_newer(ref->new_oid.hash, ref->old_oid.hash))
1594 reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
1595 }
1596
@@ -1889,7 +1889,7 @@ int get_fetch_map(const struct ref *remote_refs,
1889
1890 if (refspec->exact_sha1) {
1891 ref_map = alloc_ref(name);
1892 - get_sha1_hex(name, ref_map->old_sha1);
1892 + get_oid_hex(name, &ref_map->old_oid);
1893 } else {
1894 ref_map = get_remote_ref(remote_refs, name);
1895 }
@@ -1930,7 +1930,7 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)
1930 return 0;
1931 for (; list; list = list->next)
1932 if (!strcmp(ref->symref, list->name)) {
1933 - hashcpy(ref->old_sha1, list->old_sha1);
1933 + oidcpy(&ref->old_oid, &list->old_oid);
1934 return 0;
1935 }
1936 return 1;
@@ -2140,7 +2140,7 @@ static int one_local_ref(const char *refname, const struct object_id *oid,
2140
2141 len = strlen(refname) + 1;
2142 ref = xcalloc(1, sizeof(*ref) + len);
2143 - hashcpy(ref->new_sha1, oid->hash);
2143 + oidcpy(&ref->new_oid, oid);
2144 memcpy(ref->name, refname, len);
2145 **local_tail = ref;
2146 *local_tail = &ref->next;
@@ -2177,7 +2177,7 @@ struct ref *guess_remote_head(const struct ref *head,
2177 /* If refs/heads/master could be right, it is. */
2178 if (!all) {
2179 r = find_ref_by_name(refs, "refs/heads/master");
2180 - if (r && !hashcmp(r->old_sha1, head->old_sha1))
2180 + if (r && !oidcmp(&r->old_oid, &head->old_oid))
2181 return copy_ref(r);
2182 }
2183
@@ -2185,7 +2185,7 @@ struct ref *guess_remote_head(const struct ref *head,
2185 for (r = refs; r; r = r->next) {
2186 if (r != head &&
2187 starts_with(r->name, "refs/heads/") &&
2188 - !hashcmp(r->old_sha1, head->old_sha1)) {
2188 + !oidcmp(&r->old_oid, &head->old_oid)) {
2189 *tail = copy_ref(r);
2190 tail = &((*tail)->next);
2191 if (!all)
@@ -2233,7 +2233,7 @@ static int get_stale_heads_cb(const char *refname, const struct object_id *oid,
2233
2234 if (stale) {
2235 struct ref *ref = make_linked_ref(refname, &info->stale_refs_tail);
2236 - hashcpy(ref->new_sha1, oid->hash);
2236 + oidcpy(&ref->new_oid, oid);
2237 }
2238
2239 clean_exit:
@@ -2353,8 +2353,8 @@ static void apply_cas(struct push_cas_option *cas,
2353 continue;
2354 ref->expect_old_sha1 = 1;
2355 if (!entry->use_tracking)
2356 - hashcpy(ref->old_sha1_expect, cas->entry[i].expect);
2357 - else if (remote_tracking(remote, ref->name, ref->old_sha1_expect))
2356 + hashcpy(ref->old_oid_expect.hash, cas->entry[i].expect);
2357 + else if (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))
2358 ref->expect_old_no_trackback = 1;
2359 return;
2360 }
@@ -2364,7 +2364,7 @@ static void apply_cas(struct push_cas_option *cas,
2364 return;
2365
2366 ref->expect_old_sha1 = 1;
2367 - if (remote_tracking(remote, ref->name, ref->old_sha1_expect))
2367 + if (remote_tracking(remote, ref->name, ref->old_oid_expect.hash))
2368 ref->expect_old_no_trackback = 1;
2369 }
2370
remote.h
+3 -3
@@ -79,9 +79,9 @@ extern const struct refspec *tag_refspec;
79
80 struct ref {
81 struct ref *next;
82 - unsigned char old_sha1[20];
83 - unsigned char new_sha1[20];
84 - unsigned char old_sha1_expect[20]; /* used by expect-old */
82 + struct object_id old_oid;
83 + struct object_id new_oid;
84 + struct object_id old_oid_expect; /* used by expect-old */
85 char *symref;
86 unsigned int
87 force:1,
send-pack.c
+8 -8
@@ -102,11 +102,11 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
102 break;
103
104 while (refs) {
105 - if (!is_null_sha1(refs->old_sha1) &&
106 - !feed_object(refs->old_sha1, po.in, 1))
105 + if (!is_null_oid(&refs->old_oid) &&
106 + !feed_object(refs->old_oid.hash, po.in, 1))
107 break;
108 - if (!is_null_sha1(refs->new_sha1) &&
109 - !feed_object(refs->new_sha1, po.in, 0))
108 + if (!is_null_oid(&refs->new_oid) &&
109 + !feed_object(refs->new_oid.hash, po.in, 0))
110 break;
111 refs = refs->next;
112 }
@@ -284,8 +284,8 @@ static int generate_push_cert(struct strbuf *req_buf,
284 continue;
285 update_seen = 1;
286 strbuf_addf(&cert, "%s %s %s\n",
287 - sha1_to_hex(ref->old_sha1),
288 - sha1_to_hex(ref->new_sha1),
287 + oid_to_hex(&ref->old_oid),
288 + oid_to_hex(&ref->new_oid),
289 ref->name);
290 }
291 if (!update_seen)
@@ -487,8 +487,8 @@ int send_pack(struct send_pack_args *args,
487 if (check_to_send_update(ref, args) < 0)
488 continue;
489
490 - old_hex = sha1_to_hex(ref->old_sha1);
491 - new_hex = sha1_to_hex(ref->new_sha1);
490 + old_hex = oid_to_hex(&ref->old_oid);
491 + new_hex = oid_to_hex(&ref->new_oid);
492 if (!cmds_sent) {
493 packet_buf_write(&req_buf,
494 "%s %s %s%c%s",
transport-helper.c
+9 -9
@@ -346,7 +346,7 @@ static int fetch_with_fetch(struct transport *transport,
346 continue;
347
348 strbuf_addf(&buf, "fetch %s %s\n",
349 - sha1_to_hex(posn->old_sha1),
349 + oid_to_hex(&posn->old_oid),
350 posn->symref ? posn->symref : posn->name);
351 }
352
@@ -489,7 +489,7 @@ static int fetch_with_import(struct transport *transport,
489 else
490 private = xstrdup(name);
491 if (private) {
492 - if (read_ref(private, posn->old_sha1) < 0)
492 + if (read_ref(private, posn->old_oid.hash) < 0)
493 die("Could not read ref %s", private);
494 free(private);
495 }
@@ -756,7 +756,7 @@ static int push_update_refs_status(struct helper_data *data,
756 private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
757 if (!private)
758 continue;
759 - update_ref("update by helper", private, ref->new_sha1, NULL, 0, 0);
759 + update_ref("update by helper", private, ref->new_oid.hash, NULL, 0, 0);
760 free(private);
761 }
762 strbuf_release(&buf);
@@ -818,7 +818,7 @@ static int push_refs_with_push(struct transport *transport,
818 if (ref->peer_ref)
819 strbuf_addstr(&buf, ref->peer_ref->name);
820 else
821 - strbuf_addstr(&buf, sha1_to_hex(ref->new_sha1));
821 + strbuf_addstr(&buf, oid_to_hex(&ref->new_oid));
822 }
823 strbuf_addch(&buf, ':');
824 strbuf_addstr(&buf, ref->name);
@@ -827,14 +827,14 @@ static int push_refs_with_push(struct transport *transport,
827 /*
828 * The "--force-with-lease" options without explicit
829 * values to expect have already been expanded into
830 - * the ref->old_sha1_expect[] field; we can ignore
830 + * the ref->old_oid_expect[] field; we can ignore
831 * transport->smart_options->cas altogether and instead
832 * can enumerate them from the refs.
833 */
834 if (ref->expect_old_sha1) {
835 struct strbuf cas = STRBUF_INIT;
836 strbuf_addf(&cas, "%s:%s",
837 - ref->name, sha1_to_hex(ref->old_sha1_expect));
837 + ref->name, oid_to_hex(&ref->old_oid_expect));
838 string_list_append(&cas_options, strbuf_detach(&cas, NULL));
839 }
840 }
@@ -884,7 +884,7 @@ static int push_refs_with_export(struct transport *transport,
884 if (private && !get_sha1(private, sha1)) {
885 strbuf_addf(&buf, "^%s", private);
886 string_list_append(&revlist_args, strbuf_detach(&buf, NULL));
887 - hashcpy(ref->old_sha1, sha1);
887 + hashcpy(ref->old_oid.hash, sha1);
888 }
889 free(private);
890
@@ -1016,12 +1016,12 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
1016 if (buf.buf[0] == '@')
1017 (*tail)->symref = xstrdup(buf.buf + 1);
1018 else if (buf.buf[0] != '?')
1019 - get_sha1_hex(buf.buf, (*tail)->old_sha1);
1019 + get_oid_hex(buf.buf, &(*tail)->old_oid);
1020 if (eon) {
1021 if (has_attribute(eon + 1, "unchanged")) {
1022 (*tail)->status |= REF_STATUS_UPTODATE;
1023 if (read_ref((*tail)->name,
1024 - (*tail)->old_sha1) < 0)
1024 + (*tail)->old_oid.hash) < 0)
1025 die(N_("Could not read ref %s"),
1026 (*tail)->name);
1027 }
transport.c
+16 -16
@@ -79,7 +79,7 @@ static int read_loose_refs(struct strbuf *path, int name_offset,
79 continue;
80 next = alloc_ref(path->buf + name_offset);
81 if (read_in_full(fd, buffer, 40) != 40 ||
82 - get_sha1_hex(buffer, next->old_sha1)) {
82 + get_oid_hex(buffer, &next->old_oid)) {
83 close(fd);
84 free(next);
85 continue;
@@ -131,7 +131,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
131 if (!(*list)->next || cmp < 0) {
132 struct ref *next = alloc_ref(buffer + 41);
133 buffer[40] = '\0';
134 - if (get_sha1_hex(buffer, next->old_sha1)) {
134 + if (get_oid_hex(buffer, &next->old_oid)) {
135 warning ("invalid SHA-1: %s", buffer);
136 free(next);
137 continue;
@@ -162,7 +162,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
162 continue;
163 if (!ref->peer_ref)
164 continue;
165 - if (is_null_sha1(ref->new_sha1))
165 + if (is_null_oid(&ref->new_oid))
166 continue;
167
168 /* Follow symbolic refs (mainly for HEAD). */
@@ -412,7 +412,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus
412 for (i = 0; i < data->header.references.nr; i++) {
413 struct ref_list_entry *e = data->header.references.list + i;
414 struct ref *ref = alloc_ref(e->name);
415 - hashcpy(ref->old_sha1, e->sha1);
415 + hashcpy(ref->old_oid.hash, e->sha1);
416 ref->next = result;
417 result = ref;
418 }
@@ -608,7 +608,7 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v
608 delete_ref(rs.dst, NULL, 0);
609 } else
610 update_ref("update by push", rs.dst,
611 - ref->new_sha1, NULL, 0, 0);
611 + ref->new_oid.hash, NULL, 0, 0);
612 free(rs.dst);
613 }
614 }
@@ -648,7 +648,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
648 {
649 if (ref->deletion)
650 print_ref_status('-', "[deleted]", ref, NULL, NULL, porcelain);
651 - else if (is_null_sha1(ref->old_sha1))
651 + else if (is_null_oid(&ref->old_oid))
652 print_ref_status('*',
653 (starts_with(ref->name, "refs/tags/") ? "[new tag]" :
654 "[new branch]"),
@@ -658,7 +658,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
658 char type;
659 const char *msg;
660
661 - strbuf_addstr(&quickref, status_abbrev(ref->old_sha1));
661 + strbuf_addstr(&quickref, status_abbrev(ref->old_oid.hash));
662 if (ref->forced_update) {
663 strbuf_addstr(&quickref, "...");
664 type = '+';
@@ -668,7 +668,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
668 type = ' ';
669 msg = NULL;
670 }
671 - strbuf_addstr(&quickref, status_abbrev(ref->new_sha1));
671 + strbuf_addstr(&quickref, status_abbrev(ref->new_oid.hash));
672
673 print_ref_status(type, quickref.buf, ref, ref->peer_ref, msg, porcelain);
674 strbuf_release(&quickref);
@@ -1137,8 +1137,8 @@ static int run_pre_push_hook(struct transport *transport,
1137
1138 strbuf_reset(&buf);
1139 strbuf_addf( &buf, "%s %s %s %s\n",
1140 - r->peer_ref->name, sha1_to_hex(r->new_sha1),
1141 - r->name, sha1_to_hex(r->old_sha1));
1140 + r->peer_ref->name, oid_to_hex(&r->new_oid),
1141 + r->name, oid_to_hex(&r->old_oid));
1142
1143 if (write_in_full(proc.in, buf.buf, buf.len) != buf.len) {
1144 ret = -1;
@@ -1218,8 +1218,8 @@ int transport_push(struct transport *transport,
1218 if ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && !is_bare_repository()) {
1219 struct ref *ref = remote_refs;
1220 for (; ref; ref = ref->next)
1221 - if (!is_null_sha1(ref->new_sha1) &&
1222 - !push_unpushed_submodules(ref->new_sha1,
1221 + if (!is_null_oid(&ref->new_oid) &&
1222 + !push_unpushed_submodules(ref->new_oid.hash,
1223 transport->remote->name))
1224 die ("Failed to push all needed submodules!");
1225 }
@@ -1230,8 +1230,8 @@ int transport_push(struct transport *transport,
1230 struct string_list needs_pushing = STRING_LIST_INIT_DUP;
1231
1232 for (; ref; ref = ref->next)
1233 - if (!is_null_sha1(ref->new_sha1) &&
1234 - find_unpushed_submodules(ref->new_sha1,
1233 + if (!is_null_oid(&ref->new_oid) &&
1234 + find_unpushed_submodules(ref->new_oid.hash,
1235 transport->remote->name, &needs_pushing))
1236 die_with_unpushed_submodules(&needs_pushing);
1237 }
@@ -1284,8 +1284,8 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
1284 for (rm = refs; rm; rm = rm->next) {
1285 nr_refs++;
1286 if (rm->peer_ref &&
1287 - !is_null_sha1(rm->old_sha1) &&
1288 - !hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
1287 + !is_null_oid(&rm->old_oid) &&
1288 + !oidcmp(&rm->peer_ref->old_oid, &rm->old_oid))
1289 continue;
1290 ALLOC_GROW(heads, nr_heads + 1, nr_alloc);
1291 heads[nr_heads++] = rm;
transport.h
+4 -4
@@ -74,15 +74,15 @@ struct transport {
74 /**
75 * Push the objects and refs. Send the necessary objects, and
76 * then, for any refs where peer_ref is set and
77 - * peer_ref->new_sha1 is different from old_sha1, tell the
78 - * remote side to update each ref in the list from old_sha1 to
79 - * peer_ref->new_sha1.
77 + * peer_ref->new_oid is different from old_oid, tell the
78 + * remote side to update each ref in the list from old_oid to
79 + * peer_ref->new_oid.
80 *
81 * Where possible, set the status for each ref appropriately.
82 *
83 * The transport must modify new_sha1 in the ref to the new
84 * value if the remote accepted the change. Note that this
85 - * could be a different value from peer_ref->new_sha1 if the
85 + * could be a different value from peer_ref->new_oid if the
86 * process involved generating new commits.
87 **/
88 int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
walker.c
+1 -1
@@ -190,7 +190,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
190 if (!check_refname_format(target, 0)) {
191 struct ref *ref = alloc_ref(target);
192 if (!walker->fetch_ref(walker, ref)) {
193 - hashcpy(sha1, ref->old_sha1);
193 + hashcpy(sha1, ref->old_oid.hash);
194 free(ref);
195 return 0;
196 }