Skip to content

Commit 8eb9460

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 1e4085a commit 8eb9460

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

http-push.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ static int remote_exists(const char *path)
15361536
return ret;
15371537
}
15381538

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)
15401540
{
15411541
char *url = xstrfmt("%s%s", repo->url, path);
15421542
struct strbuf buffer = STRBUF_INIT;
@@ -1549,7 +1549,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
15491549

15501550
free(*symref);
15511551
*symref = NULL;
1552-
hashclr(sha1);
1552+
oidclr(oid);
15531553

15541554
if (buffer.len == 0)
15551555
return;
@@ -1561,15 +1561,15 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
15611561
if (skip_prefix(buffer.buf, "ref: ", &name)) {
15621562
*symref = xmemdupz(name, buffer.len - (name - buffer.buf));
15631563
} else {
1564-
get_sha1_hex(buffer.buf, sha1);
1564+
get_oid_hex(buffer.buf, oid);
15651565
}
15661566

15671567
strbuf_release(&buffer);
15681568
}
15691569

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)
15711571
{
1572-
struct commit *head = lookup_commit_or_die(head_sha1, "HEAD");
1572+
struct commit *head = lookup_commit_or_die(head_oid->hash, "HEAD");
15731573
struct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);
15741574

15751575
return in_merge_bases(branch, head);
@@ -1579,7 +1579,7 @@ static int delete_remote_branch(const char *pattern, int force)
15791579
{
15801580
struct ref *refs = remote_refs;
15811581
struct ref *remote_ref = NULL;
1582-
unsigned char head_sha1[20];
1582+
struct object_id head_oid;
15831583
char *symref = NULL;
15841584
int match;
15851585
int patlen = strlen(pattern);
@@ -1610,7 +1610,7 @@ static int delete_remote_branch(const char *pattern, int force)
16101610
* Remote HEAD must be a symref (not exactly foolproof; a remote
16111611
* symlink to a symref will look like a symref)
16121612
*/
1613-
fetch_symref("HEAD", &symref, head_sha1);
1613+
fetch_symref("HEAD", &symref, &head_oid);
16141614
if (!symref)
16151615
return error("Remote HEAD is not a symref");
16161616

@@ -1619,18 +1619,18 @@ static int delete_remote_branch(const char *pattern, int force)
16191619
if (!strcmp(remote_ref->name, symref))
16201620
return error("Remote branch %s is the current HEAD",
16211621
remote_ref->name);
1622-
fetch_symref(symref, &symref, head_sha1);
1622+
fetch_symref(symref, &symref, &head_oid);
16231623
}
16241624

16251625
/* Run extra sanity checks if delete is not forced */
16261626
if (!force) {
16271627
/* Remote HEAD must resolve to a known object */
16281628
if (symref)
16291629
return error("Remote HEAD symrefs too deep");
1630-
if (is_null_sha1(head_sha1))
1630+
if (is_null_oid(&head_oid))
16311631
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));
16341634

16351635
/* Remote branch must resolve to a known object */
16361636
if (is_null_oid(&remote_ref->old_oid))
@@ -1640,7 +1640,7 @@ static int delete_remote_branch(const char *pattern, int force)
16401640
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));
16411641

16421642
/* 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)) {
16441644
return error("The branch '%s' is not an ancestor "
16451645
"of your current HEAD.\n"
16461646
"If you are sure you want to delete it,"

0 commit comments

Comments
 (0)