On 06/07, Johannes Schindelin wrote:
> Git has this feature where suggests similar commands (including aliases)

nit: s/where/which/

> in case that the user specified an unknown command.

s/that//

> 
> This feature currently relies on a side effect of the way we expand
> aliases right now: when a command is not a builtin, we use the regular
> config machinery (meaning: discovering the .git/ directory and
> initializing global state such as the config cache) to see whether the
> command refers to an alias.
> 
> However, we will change the way aliases are expanded in the next
> commits, to use the early config instead. That means that the
> autocorrect feature can no longer discover the available aliases by
> looking at the config cache (because it has not yet been initialized).
> 
> So let's just use the early config machinery instead.
> 
> This is slightly less performant than the previous way, as the early
> config is used *twice*: once to see whether the command refers to an
> alias, and then to see what aliases are most similar. However, this is
> hardly a performance-critical code path, so performance is less important
> here.

Agreed, and it is more important to be correct than performant.

> 
> Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
> ---
>  help.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/help.c b/help.c
> index db7f3d79a01..b44c55ec2da 100644
> --- a/help.c
> +++ b/help.c
> @@ -289,7 +289,7 @@ const char *help_unknown_cmd(const char *cmd)
>       memset(&other_cmds, 0, sizeof(other_cmds));
>       memset(&aliases, 0, sizeof(aliases));
>  
> -     git_config(git_unknown_cmd_config, NULL);
> +     read_early_config(git_unknown_cmd_config, NULL);
>  
>       load_command_list("git-", &main_cmds, &other_cmds);
>  
> -- 
> 2.13.0.windows.1.460.g13f583bedb5
> 
> 

-- 
Brandon Williams

Reply via email to