refs: loosen over-strict "format" check
The add_extra_ref() interface is used to add an extra-ref that is _not_ our ref for the purpose of helping auto-following of tags and reducing object transfer from remote repository, and they are typically formatted as a tagname followed by ^{} to make sure no valid refs match that pattern. In other words, these entries are deliberately formatted not to pass check-refname-format test. A recent series however added a test unconditionally to the add_ref() function that is called from add_extra_ref(). The check may be sensible for other two callsites of the add_ref() interface, but definitely is a wrong thing to do in add_extra_ref(). Disable it. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>maint
parent
5e1e6b93d0
commit
09116a1c31
14
refs.c
14
refs.c
|
@ -48,7 +48,7 @@ static const char *parse_ref_line(char *line, unsigned char *sha1)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_ref(const char *name, const unsigned char *sha1,
|
static void add_ref(const char *name, const unsigned char *sha1,
|
||||||
int flag, struct ref_array *refs,
|
int flag, int check_name, struct ref_array *refs,
|
||||||
struct ref_entry **new_entry)
|
struct ref_entry **new_entry)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -59,7 +59,8 @@ static void add_ref(const char *name, const unsigned char *sha1,
|
||||||
entry = xmalloc(sizeof(struct ref_entry) + len);
|
entry = xmalloc(sizeof(struct ref_entry) + len);
|
||||||
hashcpy(entry->sha1, sha1);
|
hashcpy(entry->sha1, sha1);
|
||||||
hashclr(entry->peeled);
|
hashclr(entry->peeled);
|
||||||
if (check_refname_format(name, REFNAME_ALLOW_ONELEVEL|REFNAME_DOT_COMPONENT))
|
if (check_name &&
|
||||||
|
check_refname_format(name, REFNAME_ALLOW_ONELEVEL|REFNAME_DOT_COMPONENT))
|
||||||
die("Reference has invalid format: '%s'", name);
|
die("Reference has invalid format: '%s'", name);
|
||||||
memcpy(entry->name, name, len);
|
memcpy(entry->name, name, len);
|
||||||
entry->flag = flag;
|
entry->flag = flag;
|
||||||
|
@ -234,7 +235,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
|
||||||
|
|
||||||
name = parse_ref_line(refline, sha1);
|
name = parse_ref_line(refline, sha1);
|
||||||
if (name) {
|
if (name) {
|
||||||
add_ref(name, sha1, flag, array, &last);
|
add_ref(name, sha1, flag, 1, array, &last);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (last &&
|
if (last &&
|
||||||
|
@ -249,7 +250,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)
|
||||||
|
|
||||||
void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
|
void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
|
||||||
{
|
{
|
||||||
add_ref(name, sha1, flag, &extra_refs, NULL);
|
add_ref(name, sha1, flag, 0, &extra_refs, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_extra_refs(void)
|
void clear_extra_refs(void)
|
||||||
|
@ -333,12 +334,11 @@ static void get_ref_dir(const char *submodule, const char *base,
|
||||||
hashclr(sha1);
|
hashclr(sha1);
|
||||||
flag |= REF_ISBROKEN;
|
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_ISBROKEN;
|
flag |= REF_ISBROKEN;
|
||||||
}
|
}
|
||||||
add_ref(ref, sha1, flag, array, NULL);
|
add_ref(ref, sha1, flag, 1, array, NULL);
|
||||||
}
|
}
|
||||||
free(ref);
|
free(ref);
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
|
@ -146,4 +146,11 @@ test_expect_success 'cloning with reference being subset of source (-l -s)' \
|
||||||
|
|
||||||
cd "$base_dir"
|
cd "$base_dir"
|
||||||
|
|
||||||
|
test_expect_success 'clone with reference from a tagged repository' '
|
||||||
|
(
|
||||||
|
cd A && git tag -a -m 'tagged' HEAD
|
||||||
|
) &&
|
||||||
|
git clone --reference=A A I
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue