summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-04-22 19:52:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-01 22:33:10 (GMT)
commit2312a7932080f17c2847ec3ce5dddbc65c2e0b41 (patch)
treea3fbe27bc6745af79eea92a4daea0b354153ccb7 /refs.c
parent68cf87034402500f0c5dfb8d618b98b4e09895a7 (diff)
downloadgit-2312a7932080f17c2847ec3ce5dddbc65c2e0b41.zip
git-2312a7932080f17c2847ec3ce5dddbc65c2e0b41.tar.gz
git-2312a7932080f17c2847ec3ce5dddbc65c2e0b41.tar.bz2
peel_ref(): fix return value for non-peelable, not-current reference
The old version was inconsistent: when a reference was REF_KNOWS_PEELED but with a null peeled value, it returned non-zero for the current reference but zero for other references. Change the behavior for non-current references to match that of current_ref, which is what callers expect. Document the behavior. Current callers only call peel_ref() from within a for_each_ref-style iteration and only for the current ref; therefore, the buggy code path was never reached. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index 7405d1c..787db21 100644
--- a/refs.c
+++ b/refs.c
@@ -119,7 +119,8 @@ struct ref_value {
/*
* If REF_KNOWS_PEELED, then this field holds the peeled value
* of this reference, or null if the reference is known not to
- * be peelable.
+ * be peelable. See the documentation for peel_ref() for an
+ * exact definition of "peelable".
*/
unsigned char peeled[20];
};
@@ -1340,6 +1341,8 @@ int peel_ref(const char *refname, unsigned char *sha1)
struct ref_entry *r = get_packed_ref(refname);
if (r && (r->flag & REF_KNOWS_PEELED)) {
+ if (is_null_sha1(r->u.value.peeled))
+ return -1;
hashcpy(sha1, r->u.value.peeled);
return 0;
}