resolve_ref(): expose REF_ISBROKEN flag

Instead of keeping this as an internal API, let the callers find out the reason why resolve_ref() returned NULL is not because there was no such file in $GIT_DIR but because a file was corrupt. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 19, 2011 at 13:45 UTC 98ac34b2b1968e16fbf7f6122a53b73c6caaff49
2 files changed +9 -9
refs.c
+6 -7
@@ -4,9 +4,8 @@
4 #include "tag.h"
5 #include "dir.h"
6
7 -/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
8 -#define REF_KNOWS_PEELED 04
9 -#define REF_BROKEN 010
7 +/* ISSYMREF=0x01, ISPACKED=0x02 and ISBROKEN=0x04 are public interfaces */
8 +#define REF_KNOWS_PEELED 0x10
9
10 struct ref_list {
11 struct ref_list *next;
@@ -309,12 +308,12 @@ static struct ref_list *get_ref_dir(const char *submodule, const char *base,
308 flag = 0;
309 if (resolve_gitlink_ref(submodule, ref, sha1) < 0) {
310 hashclr(sha1);
312 - flag |= REF_BROKEN;
311 + flag |= REF_ISBROKEN;
312 }
313 } else
314 if (!resolve_ref(ref, sha1, 1, &flag)) {
315 hashclr(sha1);
317 - flag |= REF_BROKEN;
316 + flag |= REF_ISBROKEN;
317 }
318 list = add_ref(ref, sha1, flag, list, NULL);
319 }
@@ -613,8 +612,8 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
612 return 0;
613
614 if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
616 - if (entry->flag & REF_BROKEN)
617 - return 0; /* ignore dangling symref */
615 + if (entry->flag & REF_ISBROKEN)
616 + return 0; /* ignore broken refs e.g. dangling symref */
617 if (!has_sha1_file(entry->sha1)) {
618 error("%s does not point to a valid object!", entry->name);
619 return 0;
refs.h
+3 -2
@@ -10,8 +10,9 @@ struct ref_lock {
10 int force_write;
11 };
12
13 -#define REF_ISSYMREF 01
14 -#define REF_ISPACKED 02
13 +#define REF_ISSYMREF 0x01
14 +#define REF_ISPACKED 0x02
15 +#define REF_ISBROKEN 0x04
16
17 /*
18 * Calls the specified function for each ref file until it returns nonzero,