On Tue, Jan 26, 2021 at 05:11:42PM -0800, Junio C Hamano wrote:
Jonathan Tan [off-list ref] writes:
quoted
Thanks, Peff, for your review. I have addressed your comments (through
replies to your emails and here in this v5 patch set).
Jonathan Tan (3):
ls-refs: report unborn targets of symrefs
connect, transport: encapsulate arg in struct
clone: respect remote unborn HEAD
Applying this alone to 'master' seems to pass all tests, but
the topic seems to have funny interactions with another topic
in flight, jk/peel-iterated-oid
I was worried at first I really screwed up something subtle, but it is
indeed just a funny local interaction.
Here's a fix which can be applied on top of jt/clone-unborn-head. It
could equally well be applied as part of the merge (with a minor
adjustment in the context), but I think it ought to be squashed into
Jonathan's patch 1 anyway.
The conflict you had to resolve was a red herring (it wasn't part of
jk/peel-iterated-oid at all, but rather other commits that got pulled in
because my topic is based on a more recent master).
-- >8 --
Subject: [PATCH] ls-refs: don't peel NULL oid
When the "unborn" feature is enabled, upload-pack serving an ls-refs
command will pass a NULL oid into send_ref(). In this case, there is no
point trying to peel the ref, since we know it points to nothing.
For now this is a harmless waste of cycles (we re-resolve HEAD and find
out that indeed, it points to nothing). But after merging with another
topic that contains 36a317929b (refs: switch peel_ref() to
peel_iterated_oid(), 2021-01-20), we'd actually end up passing NULL to
peel_object(), which segfaults!
Signed-off-by: Jeff King <redacted>
---
ls-refs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ls-refs.c b/ls-refs.c
index 4077adeb6a..bc91f03653 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -66,7 +66,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
strip_namespace(symref_target));
}
- if (data->peel) {
+ if (data->peel && oid) {
struct object_id peeled;
if (!peel_ref(refname, &peeled))
strbuf_addf(&refline, " peeled:%s", oid_to_hex(&peeled));--
2.30.0.724.gc858251c49