Skip to content

Commit f551707

Browse files
mhaggergitster
authored andcommitted
read_loose_refs(): simplify function logic
Make it clearer that there are two possible ways to read the reference, but that we handle read errors uniformly regardless of which way it was read. This refactoring also makes the following change easier to implement. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8afc493 commit f551707

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

refs.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,19 +1281,24 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)
12811281
create_dir_entry(refs, refname.buf,
12821282
refname.len, 1));
12831283
} else {
1284+
int read_ok;
1285+
12841286
if (*refs->name) {
12851287
hashclr(sha1);
12861288
flag = 0;
1287-
if (resolve_gitlink_ref(refs->name, refname.buf, sha1) < 0) {
1288-
hashclr(sha1);
1289-
flag |= REF_ISBROKEN;
1290-
}
1291-
} else if (read_ref_full(refname.buf,
1292-
RESOLVE_REF_READING,
1293-
sha1, &flag)) {
1289+
read_ok = !resolve_gitlink_ref(refs->name,
1290+
refname.buf, sha1);
1291+
} else {
1292+
read_ok = !read_ref_full(refname.buf,
1293+
RESOLVE_REF_READING,
1294+
sha1, &flag);
1295+
}
1296+
1297+
if (!read_ok) {
12941298
hashclr(sha1);
12951299
flag |= REF_ISBROKEN;
12961300
}
1301+
12971302
if (check_refname_format(refname.buf,
12981303
REFNAME_ALLOW_ONELEVEL)) {
12991304
hashclr(sha1);

0 commit comments

Comments
 (0)