Rename resolve_ref() to resolve_ref_unsafe()
resolve_ref() may return a pointer to a shared buffer and can be overwritten by the next resolve_ref() calls. Callers need to pay attention, not to keep the pointer when the next call happens. Rename with "_unsafe" suffix to warn developers (or reviewers) before introducing new call sites. This patch is generated using the following command git grep -l 'resolve_ref(' -- '*.[ch]'|xargs sed -i 's/resolve_ref(/resolve_ref_unsafe(/g' Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
96ec7b1e70
commit
8cad4744ee
2
branch.c
2
branch.c
@ -182,7 +182,7 @@ int validate_new_branchname(const char *name, struct strbuf *ref,
|
||||
const char *head;
|
||||
unsigned char sha1[20];
|
||||
|
||||
head = resolve_ref("HEAD", sha1, 0, NULL);
|
||||
head = resolve_ref_unsafe("HEAD", sha1, 0, NULL);
|
||||
if (!is_bare_repository() && head && !strcmp(head, ref->buf))
|
||||
die("Cannot force update the current branch.");
|
||||
}
|
||||
|
Reference in New Issue
Block a user