From: Duy Nguyen <email@example.com> To: Jeff King <firstname.lastname@example.org> Cc: Junio C Hamano <email@example.com>, Antonio Ospite <firstname.lastname@example.org>, Eric Wong <email@example.com>, Git Mailing List <firstname.lastname@example.org> Subject: Re: [PATCH] repository.c: always allocate 'index' at repo init time Date: Tue, 21 May 2019 17:34:02 +0700 [thread overview] Message-ID: <CACsJy8CoauTdJ1huU=w2YNbw53iea5U304yAu2oCUuTvFRaV7w@mail.gmail.com> (raw) In-Reply-To: <20190520131702.GB13474@sigill.intra.peff.net> On Mon, May 20, 2019 at 8:17 PM Jeff King <email@example.com> wrote: > The patch looks good, though I wonder if we could simplify even further > by just embedding an index into the repository object. The purpose of > having it as a pointer, I think, is so that the_repository can point to > the_index. But we could possibly hide the latter behind some macro > trickery like: > > #define the_index (the_repository->index) > > I spent a few minutes on a proof of concept patch, but it gets a bit > hairy: > > 1. There are some circular dependencies in the header files. We'd need > repository.h to depend on cache.h to get the definition of > index_state, but the latter includes repository.h. We'd need to > break the index bits out of cache.h into index.h, which in turn > requires breaking out some other parts. I did a sloppy job of it in > the patch below. > > 2. There are hundreds of spots that need to swap out "repo->index" for > "&repo->index". In the patch below I just did enough to compile > archive-zip.o, to illustrate. :) You are more thorough than me. I saw #2 first and immediately backed off (partly for a selfish reason: I have plenty of the_repo conversion patches in queue and anything touching "repo" may delay those patches even more). There's also #3 but this one is minor. So far 'struct repo' is more of a glue of things. Embedding index_state in it while leaving object_store, ref_store... pointers feels inconsistent and a bit weird. It's not a strong reason for making index_state a pointer too, but if we have to deal with pointers anyway... > So it's definitely non-trivial to go that way. I'm not sure if it's > worth the effort to switch at this point, but even if it is, your patch > seems like a good thing to do in the meantime. > > Either way, I think we could probably revert the non-test portion of my > 581d2fd9f2 (get_oid: handle NULL repo->index, 2019-05-14) after this. Yeah. I'm thinking of doing that after, scanning for similar lines too. But it looks like it's the only one. Will fix in v2. -- Duy
next prev parent reply other threads:[~2019-05-21 10:34 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-11 20:57 new segfault in master (6a6c0f10a70a6eb1) Eric Wong 2019-05-11 22:31 ` Jeff King 2019-05-11 23:02 ` Jeff King 2019-05-12 4:26 ` Duy Nguyen 2019-05-14 13:54 ` [PATCH] get_oid: handle NULL repo->index Jeff King 2019-05-14 23:38 ` Eric Wong 2019-05-15 1:24 ` Duy Nguyen 2019-05-15 1:46 ` Jeff King 2019-05-15 5:16 ` Junio C Hamano 2019-05-15 9:29 ` Duy Nguyen 2019-05-16 1:43 ` Junio C Hamano 2019-05-19 2:56 ` [PATCH] repository.c: always allocate 'index' at repo init time Nguyễn Thái Ngọc Duy 2019-05-20 13:17 ` Jeff King 2019-05-21 10:34 ` Duy Nguyen [this message] 2019-05-21 20:58 ` Jeff King 2019-05-28 16:07 ` Junio C Hamano
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CACsJy8CoauTdJ1huU=w2YNbw53iea5U304yAu2oCUuTvFRaV7w@mail.gmail.com' \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: [PATCH] repository.c: always allocate '\''index'\'' at repo init time' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).