mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 18:52:08 +00:00
normalize_name: allow more references under refs/
Allow any well-formed reference name to live under refs/ removing the condition that they be under refs/{heads,tags,remotes}/ as was the design of git. An exception is made for HEAD which is allowed to contain an OID reference in detached HEAD state. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
parent
9a53df7e0a
commit
83c95128d9
15
src/refs.c
15
src/refs.c
@ -1680,8 +1680,9 @@ static int normalize_name(char *buffer_out, const char *name, int is_oid_ref)
|
|||||||
*buffer_out++ = *current++;
|
*buffer_out++ = *current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Object id refname have to contain at least one slash */
|
/* Object id refname have to contain at least one slash, except
|
||||||
if (is_oid_ref && !contains_a_slash)
|
* for HEAD in a detached state */
|
||||||
|
if (is_oid_ref && !contains_a_slash && strcmp(name, GIT_HEAD_FILE))
|
||||||
return GIT_EINVALIDREFNAME;
|
return GIT_EINVALIDREFNAME;
|
||||||
|
|
||||||
/* A refname can not end with ".lock" */
|
/* A refname can not end with ".lock" */
|
||||||
@ -1690,9 +1691,13 @@ static int normalize_name(char *buffer_out, const char *name, int is_oid_ref)
|
|||||||
|
|
||||||
*buffer_out = '\0';
|
*buffer_out = '\0';
|
||||||
|
|
||||||
/* For object id references, name has to start with refs/(heads|tags|remotes) */
|
/*
|
||||||
if (is_oid_ref && !(!git__prefixcmp(buffer_out_start, GIT_REFS_HEADS_DIR) ||
|
* For object id references, name has to start with refs/. Again,
|
||||||
!git__prefixcmp(buffer_out_start, GIT_REFS_TAGS_DIR) || !git__prefixcmp(buffer_out_start, GIT_REFS_REMOTES_DIR)))
|
* we need to allow HEAD to be in a detached state.
|
||||||
|
*/
|
||||||
|
if (is_oid_ref &&
|
||||||
|
!(git__prefixcmp(buffer_out_start, GIT_REFS_DIR) ||
|
||||||
|
strcmp(buffer_out_start, GIT_HEAD_FILE)))
|
||||||
return GIT_EINVALIDREFNAME;
|
return GIT_EINVALIDREFNAME;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
Loading…
Reference in New Issue
Block a user