Skip to content

Commit 98ac34b

Browse files
committed
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 <[email protected]>
1 parent ff74f7f commit 98ac34b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

refs.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#include "tag.h"
55
#include "dir.h"
66

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
109

1110
struct ref_list {
1211
struct ref_list *next;
@@ -309,12 +308,12 @@ static struct ref_list *get_ref_dir(const char *submodule, const char *base,
309308
flag = 0;
310309
if (resolve_gitlink_ref(submodule, ref, sha1) < 0) {
311310
hashclr(sha1);
312-
flag |= REF_BROKEN;
311+
flag |= REF_ISBROKEN;
313312
}
314313
} else
315314
if (!resolve_ref(ref, sha1, 1, &flag)) {
316315
hashclr(sha1);
317-
flag |= REF_BROKEN;
316+
flag |= REF_ISBROKEN;
318317
}
319318
list = add_ref(ref, sha1, flag, list, NULL);
320319
}
@@ -613,8 +612,8 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
613612
return 0;
614613

615614
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 */
618617
if (!has_sha1_file(entry->sha1)) {
619618
error("%s does not point to a valid object!", entry->name);
620619
return 0;

refs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ struct ref_lock {
1010
int force_write;
1111
};
1212

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
1516

1617
/*
1718
* Calls the specified function for each ref file until it returns nonzero,

0 commit comments

Comments
 (0)