From: Justin Tobler Date: Tue, 23 Apr 2024 00:30:22 GMT Subject: Re: [PATCH 02/11] parse-options-cb: only abbreviate hashes when hash algo is known Message-ID: In-Reply-To: <5daaaed2b961841d539eb88e104db57ed95809f9.1713519789.git.ps@pks.im> On 24/04/19 11:51AM, Patrick Steinhardt wrote: > The `OPT__ABBREV()` option can be used to add an option that abbreviates > object IDs. When given an length longer than `the_hash_algo->hexsz`, s/an length/a length/ > then it will instead set the length to that maximum length. > > It may not always be guaranteed that we have `the_hash_algo` initialized > properly as the hash algortihm can only be set up after we have set up s/algortihm/algorithm/ > `the_repository`. In that case, the hash would always be truncated to > the hex length of SHA1, which may not be what the user desires. > > In practice it's not a problem as all commands that use `OPT__ABBREV()` > also have `RUN_SETUP` set and thus cannot work without a repository. > Consequently, both `the_repository` and `the_hash_algo` would be > properly set up. > > Regardless of that, harden the code to not truncate the length when we > didn't set up a repository. > > Signed-off-by: Patrick Steinhardt ... A couple of typos I noticed. -Justin