resolve_ref_1(): eliminate local variable "bad_name"
We can use (*flags & REF_BAD_NAME) for that purpose. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e6702e570b
commit
afbe782fa3
@ -1399,19 +1399,17 @@ static const char *resolve_ref_1(const char *refname,
|
|||||||
struct strbuf *sb_path,
|
struct strbuf *sb_path,
|
||||||
struct strbuf *sb_contents)
|
struct strbuf *sb_contents)
|
||||||
{
|
{
|
||||||
int bad_name = 0;
|
|
||||||
int symref_count;
|
int symref_count;
|
||||||
|
|
||||||
*flags = 0;
|
*flags = 0;
|
||||||
|
|
||||||
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
||||||
*flags |= REF_BAD_NAME;
|
|
||||||
|
|
||||||
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
||||||
!refname_is_safe(refname)) {
|
!refname_is_safe(refname)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dwim_ref() uses REF_ISBROKEN to distinguish between
|
* dwim_ref() uses REF_ISBROKEN to distinguish between
|
||||||
* missing refs and refs that were present but invalid,
|
* missing refs and refs that were present but invalid,
|
||||||
@ -1420,7 +1418,7 @@ static const char *resolve_ref_1(const char *refname,
|
|||||||
* We don't know whether the ref exists, so don't set
|
* We don't know whether the ref exists, so don't set
|
||||||
* REF_ISBROKEN yet.
|
* REF_ISBROKEN yet.
|
||||||
*/
|
*/
|
||||||
bad_name = 1;
|
*flags |= REF_BAD_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (symref_count = 0; symref_count < MAXDEPTH; symref_count++) {
|
for (symref_count = 0; symref_count < MAXDEPTH; symref_count++) {
|
||||||
@ -1452,7 +1450,7 @@ static const char *resolve_ref_1(const char *refname,
|
|||||||
}
|
}
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
}
|
}
|
||||||
if (bad_name) {
|
if (*flags & REF_BAD_NAME) {
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
*flags |= REF_ISBROKEN;
|
*flags |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
@ -1524,7 +1522,7 @@ static const char *resolve_ref_1(const char *refname,
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (bad_name) {
|
if (*flags & REF_BAD_NAME) {
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
*flags |= REF_ISBROKEN;
|
*flags |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
@ -1548,8 +1546,7 @@ static const char *resolve_ref_1(const char *refname,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*flags |= REF_ISBROKEN;
|
*flags |= REF_ISBROKEN | REF_BAD_NAME;
|
||||||
bad_name = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user