refs: Do not union the peel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 730148a..784749f 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -645,7 +645,7 @@ static int loose_write(refdb_fs_backend *backend, const git_reference *ref)
if (ref->type == GIT_REF_OID) {
char oid[GIT_OID_HEXSZ + 1];
- git_oid_fmt(oid, &ref->target.direct.oid);
+ git_oid_fmt(oid, &ref->target.oid);
oid[GIT_OID_HEXSZ] = '\0';
git_filebuf_printf(&file, "%s\n", oid);
diff --git a/src/refs.c b/src/refs.c
index 982cd05..29d1c4f 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -83,10 +83,10 @@ git_reference *git_reference__alloc(
return NULL;
ref->type = GIT_REF_OID;
- git_oid_cpy(&ref->target.direct.oid, oid);
+ git_oid_cpy(&ref->target.oid, oid);
if (peel != NULL)
- git_oid_cpy(&ref->target.direct.peel, peel);
+ git_oid_cpy(&ref->peel, peel);
return ref;
}
@@ -322,17 +322,17 @@ const git_oid *git_reference_target(const git_reference *ref)
if (ref->type != GIT_REF_OID)
return NULL;
- return &ref->target.direct.oid;
+ return &ref->target.oid;
}
const git_oid *git_reference_target_peel(const git_reference *ref)
{
assert(ref);
- if (ref->type != GIT_REF_OID || git_oid_iszero(&ref->target.direct.peel))
+ if (ref->type != GIT_REF_OID || git_oid_iszero(&ref->peel))
return NULL;
- return &ref->target.direct.peel;
+ return &ref->peel;
}
const char *git_reference_symbolic_target(const git_reference *ref)
@@ -491,7 +491,7 @@ int git_reference_rename(
*/
if (ref->type == GIT_REF_OID) {
result = git_reference__alloc(ref->db, new_name,
- &ref->target.direct.oid, &ref->target.direct.peel);
+ &ref->target.oid, &ref->peel);
} else if (ref->type == GIT_REF_SYMBOLIC) {
result = git_reference__alloc_symbolic(ref->db, new_name, ref->target.symbolic);
} else {
@@ -833,7 +833,7 @@ int git_reference_cmp(git_reference *ref1, git_reference *ref2)
if (type1 == GIT_REF_SYMBOLIC)
return strcmp(ref1->target.symbolic, ref2->target.symbolic);
- return git_oid_cmp(&ref1->target.direct.oid, &ref2->target.direct.oid);
+ return git_oid_cmp(&ref1->target.oid, &ref2->target.oid);
}
static int reference__update_terminal(
@@ -969,12 +969,12 @@ int git_reference_peel(
return peel_error(error, ref, "Cannot resolve reference");
}
- if (!git_oid_iszero(&resolved->target.direct.peel)) {
+ if (!git_oid_iszero(&resolved->peel)) {
error = git_object_lookup(&target,
- git_reference_owner(ref), &resolved->target.direct.peel, GIT_OBJ_ANY);
+ git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY);
} else {
error = git_object_lookup(&target,
- git_reference_owner(ref), &resolved->target.direct.oid, GIT_OBJ_ANY);
+ git_reference_owner(ref), &resolved->target.oid, GIT_OBJ_ANY);
}
if (error < 0) {
diff --git a/src/refs.h b/src/refs.h
index b0aa56a..97d4d2e 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -52,14 +52,11 @@ struct git_reference {
git_ref_t type;
union {
- struct {
- git_oid oid;
- git_oid peel;
- } direct;
-
+ git_oid oid;
char *symbolic;
} target;
-
+
+ git_oid peel;
char name[0];
};