From: Junio C Hamano Date: Tue, 29 Aug 2023 01:16:06 GMT Subject: Re: [PATCH 01/22] sequencer: use repository parameter in short_commit_name() Message-ID: In-Reply-To: <20230829004801.GA3876652@coredump.intra.peff.net> Jeff King writes: >> but that will no longer be true with the updated code. I'd feel >> safer if at the beginning of the function we create a local variable >> "struct rev_info *repo" that is initialized to opts->revs->repo and >> use it throughout the function instead of the_repository. > > I'm not sure how that makes it any safer, as it would mean using the > suspect repo pointer in more places. Unless you are proposing to do: > > struct repository *r = opts->revs->repo; > if (!r) > r = the_repository; /* or BUG() ? */ Yup, the BUG() variant was exactly what I had in mind, but without the assert, by using opts->revs->repo more consistently, we would make sure nobody will call us with uninitialized opts->revs->repo now or in the future.