From: Jonathan Tan Date: Thu, 01 Jun 2023 23:35:50 GMT Subject: Re: [PATCH v2 09/14] config.c: provide kvi with CLI config Message-ID: <20230601233550.429921-1-jonathantanmy@google.com> In-Reply-To: <3760015d2c000c59d354bae872c431ee3266e9da.1685472134.git.gitgitgadget@gmail.com> "Glen Choo via GitGitGadget" writes: > From: Glen Choo > > plumb "kvi" so that we can replace > nearly all calls to current_config_*(). (The exception is an edge case > where trace2/*.c calls current_config_scope(). Probably clearer to say: plumb "kvi" so that we can remove all calls of current_config_scope() except from trace2/*.c (which will be handled in a later commit), and remove all other current_config_*() (the functions themselves and their calls). > Plumbing "kvi" reveals a few places where we've been doing the wrong > thing: > > * git_config_parse_parameter() hasn't been setting config source > information, so plumb "kvi" there too. > > * "git config --get-urlmatch --show-scope" iterates config to collect > values, but then attempts to display the scope after config iteration. > Fix this by copying the "kvi" arg in the collection phase so that it > can be read back later. This means that we can now support "git config > --get-urlmatch --show-origin" (we don't allow this combination of args > because of this bug), but that is left unchanged for now. > > * "git config --default" doesn't have config source metadata when > displaying the default value. Fix this by treating the default value > as if it came from the command line (e.g. like we do with "git -c" or > "git config --file"), using kvi_from_param(). > > Signed-off-by: Glen Choo Thanks for noticing and fixing these. > + memcpy(&matched->kvi, kvi, sizeof(struct key_value_info)); Can this just be matched->kvi = *kvi; ? If not, for the sizeof, use *kvi as the argument instead of struct key_value_info.