Commit 04865aa0 by Carlos Martín Nieto

local transport: expose the symref data

When using the local transport, we always have the symbolic information
available, so fill it.
parent 306475eb
......@@ -43,14 +43,19 @@ typedef struct {
static int add_ref(transport_local *t, const char *name)
{
const char peeled[] = "^{}";
git_oid head_oid;
git_reference *ref, *resolved;
git_remote_head *head;
git_oid obj_id;
git_object *obj = NULL, *target = NULL;
git_buf buf = GIT_BUF_INIT;
int error;
error = git_reference_name_to_id(&head_oid, t->repo, name);
if ((error = git_reference_lookup(&ref, t->repo, name)) < 0)
return error;
error = git_reference_resolve(&resolved, ref);
if (error < 0) {
git_reference_free(ref);
if (!strcmp(name, GIT_HEAD_FILE) && error == GIT_ENOTFOUND) {
/* This is actually okay. Empty repos often have a HEAD that
* points to a nonexistent "refs/heads/master". */
......@@ -60,13 +65,22 @@ static int add_ref(transport_local *t, const char *name)
return error;
}
git_oid_cpy(&obj_id, git_reference_target(resolved));
git_reference_free(resolved);
head = git__calloc(1, sizeof(git_remote_head));
GITERR_CHECK_ALLOC(head);
head->name = git__strdup(name);
GITERR_CHECK_ALLOC(head->name);
git_oid_cpy(&head->oid, &head_oid);
git_oid_cpy(&head->oid, &obj_id);
if (git_reference_type(ref) == GIT_REF_SYMBOLIC) {
head->symref_target = git__strdup(git_reference_symbolic_target(ref));
GITERR_CHECK_ALLOC(head->symref_target);
}
git_reference_free(ref);
if ((error = git_vector_insert(&t->refs, head)) < 0) {
git__free(head->name);
......@@ -176,7 +190,7 @@ static int path_from_url_or_path(git_buf *local_path_out, const char *url_or_pat
/*
* Try to open the url as a git directory. The direction doesn't
* matter in this case because we're calulating the heads ourselves.
* matter in this case because we're calculating the heads ourselves.
*/
static int local_connect(
git_transport *transport,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment