diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-11-13 17:22:14 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-11-13 12:21:06 -0800 |
commit | c6893323917cbf4cb66c29ba2ac03014a44f0f0c (patch) | |
tree | cc14f88d5ebfd114e5c80f74506eff6c9a5fa68b /builtin/replace.c | |
parent | bc1bbe0c19a6ff39522b4fa3259f34150e308e1f (diff) | |
download | git-c6893323917cbf4cb66c29ba2ac03014a44f0f0c.tar.gz |
Convert many resolve_ref() calls to read_ref*() and ref_exists()
resolve_ref() may return a pointer to a static buffer, which is not
safe for long-term use because if another resolve_ref() call happens,
the buffer may be changed. Many call sites though do not care about
this buffer. They simply check if the return value is NULL or not.
Convert all these call sites to new wrappers to reduce resolve_ref()
calls from 57 to 34. If we change resolve_ref() prototype later on
to avoid passing static buffer out, this helps reduce changes.
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 'builtin/replace.c')
-rw-r--r-- | builtin/replace.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/replace.c b/builtin/replace.c index 517fa1031a..4a8970e9c9 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -58,7 +58,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn) had_error = 1; continue; } - if (!resolve_ref(ref, sha1, 1, NULL)) { + if (read_ref(ref, sha1)) { error("replace ref '%s' not found.", *p); had_error = 1; continue; @@ -97,7 +97,7 @@ static int replace_object(const char *object_ref, const char *replace_ref, if (check_refname_format(ref, 0)) die("'%s' is not a valid ref name.", ref); - if (!resolve_ref(ref, prev, 1, NULL)) + if (read_ref(ref, prev)) hashclr(prev); else if (!force) die("replace ref '%s' already exists", ref); |