Merge branch 'jk/reading-packed-refs'
An earlier rewrite to use strbuf_getwholeline() instead of fgets(3) to read packed-refs file revealed that the former is unacceptably inefficient. * jk/reading-packed-refs: t1430: add another refs-escape test read_packed_refs: avoid double-checking sane refs strbuf_getwholeline: use getdelim if it is available strbuf_getwholeline: avoid calling strbuf_grow strbuf_addch: avoid calling strbuf_grow config: use getc_unlocked when reading from file strbuf_getwholeline: use getc_unlocked git-compat-util: add fallbacks for unlocked stdio strbuf_getwholeline: use getc macro
This commit is contained in:
6
refs.c
6
refs.c
@ -344,8 +344,6 @@ static struct ref_entry *create_ref_entry(const char *refname,
|
||||
if (check_name &&
|
||||
check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
|
||||
die("Reference has invalid format: '%s'", refname);
|
||||
if (!check_name && !refname_is_safe(refname))
|
||||
die("Reference has invalid name: '%s'", refname);
|
||||
len = strlen(refname) + 1;
|
||||
ref = xmalloc(sizeof(struct ref_entry) + len);
|
||||
hashcpy(ref->u.value.sha1, sha1);
|
||||
@ -1178,6 +1176,8 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
|
||||
int flag = REF_ISPACKED;
|
||||
|
||||
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
||||
if (!refname_is_safe(refname))
|
||||
die("packed refname is dangerous: %s", refname);
|
||||
hashclr(sha1);
|
||||
flag |= REF_BAD_NAME | REF_ISBROKEN;
|
||||
}
|
||||
@ -1323,6 +1323,8 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir)
|
||||
}
|
||||
if (check_refname_format(refname.buf,
|
||||
REFNAME_ALLOW_ONELEVEL)) {
|
||||
if (!refname_is_safe(refname.buf))
|
||||
die("loose refname is dangerous: %s", refname.buf);
|
||||
hashclr(sha1);
|
||||
flag |= REF_BAD_NAME | REF_ISBROKEN;
|
||||
}
|
||||
|
Reference in New Issue
Block a user