path: root/builtin/for-each-ref.c
diff options
authorRonnie Sahlberg <>2014-07-15 19:59:36 (GMT)
committerJunio C Hamano <>2014-10-15 17:47:24 (GMT)
commit7695d118e5a3c9c6fcb4cb15eb766a1c57422aed (patch)
tree53872b12d57c9f7fca48379262baff5d4f4051eb /builtin/for-each-ref.c
parentaae383db8c384dc46abe199899235f67c838e601 (diff)
refs.c: change resolve_ref_unsafe reading argument to be a flags field
resolve_ref_unsafe takes a boolean argument for reading (a nonexistent ref resolves successfully for writing but not for reading). Change this to be a flags field instead, and pass the new constant RESOLVE_REF_READING when we want this behaviour. While at it, swap two of the arguments in the function to put output arguments at the end. As a nice side effect, this ensures that we can catch callers that were unaware of the new API so they can be audited. Give the wrapper functions resolve_refdup and read_ref_full the same treatment for consistency. Signed-off-by: Ronnie Sahlberg <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/for-each-ref.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index fda0f04..492265d 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -635,7 +635,8 @@ static void populate_value(struct refinfo *ref)
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
unsigned char unused1[20];
- ref->symref = resolve_refdup(ref->refname, unused1, 1, NULL);
+ ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
+ unused1, NULL);
if (!ref->symref)
ref->symref = "";
@@ -693,7 +694,8 @@ static void populate_value(struct refinfo *ref)
const char *head;
unsigned char sha1[20];
- head = resolve_ref_unsafe("HEAD", sha1, 1, NULL);
+ head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
+ sha1, NULL);
if (!strcmp(ref->refname, head))
v->s = "*";