diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-12-12 18:20:32 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-13 09:39:46 -0800 |
commit | 8cad4744ee37ebec1d9491a1381ec1771a1ba795 (patch) | |
tree | 064bbe938f38727dd163aae9c95e2185b8075234 /remote.c | |
parent | 96ec7b1e708863d0cd6b8e72a986d6f0a1bb64db (diff) | |
download | git-8cad4744ee37ebec1d9491a1381ec1771a1ba795.tar.gz |
Rename resolve_ref() to resolve_ref_unsafe()nd/resolve-ref
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>
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -482,7 +482,7 @@ static void read_config(void) return; default_remote_name = xstrdup("origin"); current_branch = NULL; - head_ref = resolve_ref("HEAD", sha1, 0, &flag); + head_ref = resolve_ref_unsafe("HEAD", sha1, 0, &flag); if (head_ref && (flag & REF_ISSYMREF) && !prefixcmp(head_ref, "refs/heads/")) { current_branch = @@ -1007,7 +1007,7 @@ static char *guess_ref(const char *name, struct ref *peer) struct strbuf buf = STRBUF_INIT; unsigned char sha1[20]; - const char *r = resolve_ref(peer->name, sha1, 1, NULL); + const char *r = resolve_ref_unsafe(peer->name, sha1, 1, NULL); if (!r) return NULL; @@ -1058,7 +1058,7 @@ static int match_explicit(struct ref *src, struct ref *dst, unsigned char sha1[20]; int flag; - dst_value = resolve_ref(matched_src->name, sha1, 1, &flag); + dst_value = resolve_ref_unsafe(matched_src->name, sha1, 1, &flag); if (!dst_value || ((flag & REF_ISSYMREF) && prefixcmp(dst_value, "refs/heads/"))) |