Re: [PATCH 02/14] pager: stop using `the_repository`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



shejialuo <shejialuo@xxxxxxxxx> writes:

> On Tue, Dec 17, 2024 at 07:43:49AM +0100, Patrick Steinhardt wrote:
>> Stop using `the_repository` in the "pager" subsystem by passing in a
>> repository when setting up the pager and when configuring it.
>>
>> Adjust callers accordingly by using `the_repository`. While there may be
>> some callers that have a repository available in their context, this
>> trivial conversion allows for easier verification and bubbles up the use
>> of `the_repository` by one level.
>>
>> Signed-off-by: Patrick Steinhardt <ps@xxxxxx>
>> ---
>>  add-patch.c     |  2 +-
>>  builtin/am.c    |  4 ++--
>>  builtin/blame.c |  2 +-
>>  builtin/grep.c  |  4 ++--
>>  builtin/help.c  |  4 ++--
>>  builtin/log.c   |  4 ++--
>>  builtin/var.c   |  2 +-
>>  diff.c          |  4 ++--
>>  git.c           |  8 ++++----
>>  pager.c         | 14 ++++++--------
>>  pager.h         |  7 ++++---
>>  11 files changed, 27 insertions(+), 28 deletions(-)
>>
>> diff --git a/builtin/help.c b/builtin/help.c
>> index 05136279cf7b1007ab754f5630c34536a5f9461f..c257079cebc3c09fb91f258c3b0148e2f204c0e7 100644
>> --- a/builtin/help.c
>> +++ b/builtin/help.c
>> @@ -658,7 +658,7 @@ int cmd_help(int argc,
>>  	case HELP_ACTION_ALL:
>>  		opt_mode_usage(argc, "--all", help_format);
>>  		if (verbose) {
>> -			setup_pager();
>> +			setup_pager(the_repository);
>
> It's possible we run "git help" outside of the repository. Here we still
> pass "the_repository" to the "setup_pager", it may be a little strange.
> But later we will use the "repo" parameter instead of the global
> variable "the_repository", so this is OK.
>

Well, the crux here is that the pager only requires the repository for
calling `read_early_config()` in `config.c`. And that function is used
to read if there is pager config, since git allows you to setup the
pager via config. It also checks if the repo variable is set, so this
would work as expected outside of a git repository.

>>  			list_all_cmds_help(show_external_commands,
>>  					   show_aliases);
>>  			return 0;

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux