commit - 927df6b74a3358d1eaa0f2482cac2204a4f8f9fa
commit + e135804eb13a827d9984bab054db65479e341e6a
blob - 978e204964c04177074426b44f9e63c1823b2c20
blob + 419ffd3592d2e92851797182541245fcb5cbcdba
--- lib/reference.c
+++ lib/reference.c
int i, well_known = is_well_known_ref(refname);
*ref = NULL;
+
+ path_refs = get_refs_dir_path(repo, refname);
+ if (path_refs == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
if (!well_known) {
char *packed_refs_path;
FILE *f;
+ /* Search on-disk refs before packed refs! */
+ for (i = 0; i < nitems(subdirs); i++) {
+ err = open_ref(ref, path_refs, subdirs[i], refname);
+ if (err || *ref)
+ goto done;
+ }
+
packed_refs_path = got_repo_get_path_packed_refs(repo);
- if (packed_refs_path == NULL)
- return got_error_from_errno();
+ if (packed_refs_path == NULL) {
+ err = got_error_from_errno();
+ goto done;
+ }
f = fopen(packed_refs_path, "rb");
free(packed_refs_path);
}
}
- path_refs = get_refs_dir_path(repo, refname);
- if (path_refs == NULL) {
- err = got_error_from_errno();
- goto done;
- }
-
- if (!well_known) {
- for (i = 0; i < nitems(subdirs); i++) {
- err = open_ref(ref, path_refs, subdirs[i], refname);
- if (err || *ref)
- goto done;
- }
- }
-
err = open_ref(ref, path_refs, "", refname);
if (err)
goto done;
+done:
if (*ref == NULL)
err = got_error_not_ref(refname);
-done:
free(path_refs);
return err;
}