Re: [PATCH] get_oid: handle NULL repo->index

2019-05-15 Thread Junio C Hamano
Duy Nguyen writes: >> That is an approach to make it harder to make mistakes by accepting >> possibly a small wasted resource; but at that point, I think calling >> repo_read_index() unconditionally from here and similar places would >> be a simpler fix in the same spirit. > > For repo_read_index

Re: [PATCH] get_oid: handle NULL repo->index

2019-05-15 Thread Duy Nguyen
On Wed, May 15, 2019 at 12:16 PM Junio C Hamano wrote: > > Jeff King writes: > > > Also from my earlier message, if you missed it: > > > > I also wondered if we should simply allocate an empty index whenever > > we have a non-toplevel "struct repository", which might be less > > surprising

Re: [PATCH] get_oid: handle NULL repo->index

2019-05-14 Thread Junio C Hamano
Jeff King writes: > Also from my earlier message, if you missed it: > > I also wondered if we should simply allocate an empty index whenever > we have a non-toplevel "struct repository", which might be less > surprising to other callers. I don't have a strong opinion either way. > I did g

Re: [PATCH] get_oid: handle NULL repo->index

2019-05-14 Thread Jeff King
On Wed, May 15, 2019 at 08:24:34AM +0700, Duy Nguyen wrote: > On Tue, May 14, 2019 at 8:54 PM Jeff King wrote: > > diff --git a/sha1-name.c b/sha1-name.c > > index 775a73d8ad..455e9fb1ea 100644 > > --- a/sha1-name.c > > +++ b/sha1-name.c > > @@ -1837,7 +1837,7 @@ static enum get_oid_result > > g

Re: [PATCH] get_oid: handle NULL repo->index

2019-05-14 Thread Duy Nguyen
On Tue, May 14, 2019 at 8:54 PM Jeff King wrote: > diff --git a/sha1-name.c b/sha1-name.c > index 775a73d8ad..455e9fb1ea 100644 > --- a/sha1-name.c > +++ b/sha1-name.c > @@ -1837,7 +1837,7 @@ static enum get_oid_result > get_oid_with_context_1(struct repository *repo, > if (flags

Re: [PATCH] get_oid: handle NULL repo->index

2019-05-14 Thread Eric Wong
Jeff King wrote: > +++ b/sha1-name.c > @@ -1837,7 +1837,7 @@ static enum get_oid_result > get_oid_with_context_1(struct repository *repo, > if (flags & GET_OID_RECORD_PATH) > oc->path = xstrdup(cp); > > - if (!repo->index->cache) > + i

[PATCH] get_oid: handle NULL repo->index

2019-05-14 Thread Jeff King
just a silly mistake in the code to check whether the index is already initialized. Once we fix that, we don't need to handle this specifically in the submodule code. So here's a simpler, revised patch: -- >8 -- Subject: [PATCH] get_oid: handle NULL repo->index When get_oid() and its hel