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>
This commit is contained in:
13
refs.c
13
refs.c
@ -4,9 +4,8 @@
|
|||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
|
||||||
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
|
/* ISSYMREF=0x01, ISPACKED=0x02 and ISBROKEN=0x04 are public interfaces */
|
||||||
#define REF_KNOWS_PEELED 04
|
#define REF_KNOWS_PEELED 0x10
|
||||||
#define REF_BROKEN 010
|
|
||||||
|
|
||||||
struct ref_list {
|
struct ref_list {
|
||||||
struct ref_list *next;
|
struct ref_list *next;
|
||||||
@ -309,12 +308,12 @@ static struct ref_list *get_ref_dir(const char *submodule, const char *base,
|
|||||||
flag = 0;
|
flag = 0;
|
||||||
if (resolve_gitlink_ref(submodule, ref, sha1) < 0) {
|
if (resolve_gitlink_ref(submodule, ref, sha1) < 0) {
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
flag |= REF_BROKEN;
|
flag |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (!resolve_ref(ref, sha1, 1, &flag)) {
|
if (!resolve_ref(ref, sha1, 1, &flag)) {
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
flag |= REF_BROKEN;
|
flag |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
list = add_ref(ref, sha1, flag, list, NULL);
|
list = add_ref(ref, sha1, flag, list, NULL);
|
||||||
}
|
}
|
||||||
@ -613,8 +612,8 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
|
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
|
||||||
if (entry->flag & REF_BROKEN)
|
if (entry->flag & REF_ISBROKEN)
|
||||||
return 0; /* ignore dangling symref */
|
return 0; /* ignore broken refs e.g. dangling symref */
|
||||||
if (!has_sha1_file(entry->sha1)) {
|
if (!has_sha1_file(entry->sha1)) {
|
||||||
error("%s does not point to a valid object!", entry->name);
|
error("%s does not point to a valid object!", entry->name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
5
refs.h
5
refs.h
@ -10,8 +10,9 @@ struct ref_lock {
|
|||||||
int force_write;
|
int force_write;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REF_ISSYMREF 01
|
#define REF_ISSYMREF 0x01
|
||||||
#define REF_ISPACKED 02
|
#define REF_ISPACKED 0x02
|
||||||
|
#define REF_ISBROKEN 0x04
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calls the specified function for each ref file until it returns nonzero,
|
* Calls the specified function for each ref file until it returns nonzero,
|
||||||
|
|||||||
Reference in New Issue
Block a user