Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
read_loose_refs(): simplify function logic
author
Michael Haggerty
<mhagger@alum.mit.edu>
Wed, 3 Jun 2015 13:51:58 +0000
(15:51 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 3 Jun 2015 18:44:25 +0000
(11:44 -0700)
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 <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8afc493
)
diff --git
a/refs.c
b/refs.c
index 3a26ad4e65b92bc9398766169f9a236e4be0d08d..3c311d44c152000898459561222ef863a56bcc48 100644
(file)
--- a/
refs.c
+++ b/
refs.c
@@
-1281,19
+1281,24
@@
static void read_loose_refs(const char *dirname, struct ref_dir *dir)
create_dir_entry(refs, refname.buf,
refname.len, 1));
} else {
create_dir_entry(refs, refname.buf,
refname.len, 1));
} else {
+ int read_ok;
+
if (*refs->name) {
hashclr(sha1);
flag = 0;
if (*refs->name) {
hashclr(sha1);
flag = 0;
- if (resolve_gitlink_ref(refs->name, refname.buf, sha1) < 0) {
- hashclr(sha1);
- flag |= REF_ISBROKEN;
- }
- } else if (read_ref_full(refname.buf,
- RESOLVE_REF_READING,
- sha1, &flag)) {
+ read_ok = !resolve_gitlink_ref(refs->name,
+ refname.buf, sha1);
+ } else {
+ read_ok = !read_ref_full(refname.buf,
+ RESOLVE_REF_READING,
+ sha1, &flag);
+ }
+
+ if (!read_ok) {
hashclr(sha1);
flag |= REF_ISBROKEN;
}
hashclr(sha1);
flag |= REF_ISBROKEN;
}
+
if (check_refname_format(refname.buf,
REFNAME_ALLOW_ONELEVEL)) {
hashclr(sha1);
if (check_refname_format(refname.buf,
REFNAME_ALLOW_ONELEVEL)) {
hashclr(sha1);