http-push: convert some static functions to struct object_id

Among the functions converted is a caller of lookup_commit_or_die, which we will convert later on. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 6, 2017 at 22:10 UTC 8eb9460045e44065a85c1dc735bbb8fcba776146
1 file changed +12 -12
http-push.c
+12 -12
@@ -1536,7 +1536,7 @@ static int remote_exists(const char *path)
1536 return ret;
1537 }
1538
1539 -static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
1539 +static void fetch_symref(const char *path, char **symref, struct object_id *oid)
1540 {
1541 char *url = xstrfmt("%s%s", repo->url, path);
1542 struct strbuf buffer = STRBUF_INIT;
@@ -1549,7 +1549,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
1549
1550 free(*symref);
1551 *symref = NULL;
1552 - hashclr(sha1);
1552 + oidclr(oid);
1553
1554 if (buffer.len == 0)
1555 return;
@@ -1561,15 +1561,15 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
1561 if (skip_prefix(buffer.buf, "ref: ", &name)) {
1562 *symref = xmemdupz(name, buffer.len - (name - buffer.buf));
1563 } else {
1564 - get_sha1_hex(buffer.buf, sha1);
1564 + get_oid_hex(buffer.buf, oid);
1565 }
1566
1567 strbuf_release(&buffer);
1568 }
1569
1570 -static int verify_merge_base(unsigned char *head_sha1, struct ref *remote)
1570 +static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
1571 {
1572 - struct commit *head = lookup_commit_or_die(head_sha1, "HEAD");
1572 + struct commit *head = lookup_commit_or_die(head_oid->hash, "HEAD");
1573 struct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);
1574
1575 return in_merge_bases(branch, head);
@@ -1579,7 +1579,7 @@ static int delete_remote_branch(const char *pattern, int force)
1579 {
1580 struct ref *refs = remote_refs;
1581 struct ref *remote_ref = NULL;
1582 - unsigned char head_sha1[20];
1582 + struct object_id head_oid;
1583 char *symref = NULL;
1584 int match;
1585 int patlen = strlen(pattern);
@@ -1610,7 +1610,7 @@ static int delete_remote_branch(const char *pattern, int force)
1610 * Remote HEAD must be a symref (not exactly foolproof; a remote
1611 * symlink to a symref will look like a symref)
1612 */
1613 - fetch_symref("HEAD", &symref, head_sha1);
1613 + fetch_symref("HEAD", &symref, &head_oid);
1614 if (!symref)
1615 return error("Remote HEAD is not a symref");
1616
@@ -1619,7 +1619,7 @@ static int delete_remote_branch(const char *pattern, int force)
1619 if (!strcmp(remote_ref->name, symref))
1620 return error("Remote branch %s is the current HEAD",
1621 remote_ref->name);
1622 - fetch_symref(symref, &symref, head_sha1);
1622 + fetch_symref(symref, &symref, &head_oid);
1623 }
1624
1625 /* Run extra sanity checks if delete is not forced */
@@ -1627,10 +1627,10 @@ static int delete_remote_branch(const char *pattern, int force)
1627 /* Remote HEAD must resolve to a known object */
1628 if (symref)
1629 return error("Remote HEAD symrefs too deep");
1630 - if (is_null_sha1(head_sha1))
1630 + if (is_null_oid(&head_oid))
1631 return error("Unable to resolve remote HEAD");
1632 - if (!has_sha1_file(head_sha1))
1633 - return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", sha1_to_hex(head_sha1));
1632 + if (!has_object_file(&head_oid))
1633 + return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
1634
1635 /* Remote branch must resolve to a known object */
1636 if (is_null_oid(&remote_ref->old_oid))
@@ -1640,7 +1640,7 @@ static int delete_remote_branch(const char *pattern, int force)
1640 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));
1641
1642 /* Remote branch must be an ancestor of remote HEAD */
1643 - if (!verify_merge_base(head_sha1, remote_ref)) {
1643 + if (!verify_merge_base(&head_oid, remote_ref)) {
1644 return error("The branch '%s' is not an ancestor "
1645 "of your current HEAD.\n"
1646 "If you are sure you want to delete it,"