Re: [PATCH 3/5] meson: correct path to system config/attribute files

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

 




On 09/05/2025 09:51, Patrick Steinhardt wrote:
> On Thu, May 08, 2025 at 05:44:37PM +0100, Ramsay Jones wrote:
>> diff --git a/meson.build b/meson.build
>> index 48f31157a0..106cb17612 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -757,8 +757,6 @@ endif
>>  libgit_c_args = [
>>    '-DBINDIR="' + get_option('bindir') + '"',
>>    '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
>> -  '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
>> -  '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
>>    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
>>    '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
>>    '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
>> @@ -769,6 +767,18 @@ libgit_c_args = [
>>    '-DSHELL_PATH="' + fs.as_posix(target_shell.full_path()) + '"',
>>  ]
>>  
>> +system_attributes = get_option('gitattributes')
>> +if system_attributes != ''
>> +  libgit_c_args += '-DETC_GITATTRIBUTES="' + system_attributes + '"'
>> +else
>> +  libgit_c_args += '-DETC_GITATTRIBUTES="' + get_option('sysconfdir') + '/gitattributes"'
>> +endif
>> +system_config = get_option('gitconfig')
>> +if system_config != ''
>> +  libgit_c_args += '-DETC_GITCONFIG="' + system_config + '"'
>> +else
>> +  libgit_c_args += '-DETC_GITCONFIG="' + get_option('sysconfdir') + '/gitconfig"'
> 
> Instead of `get_option('sysconfdir') + '/gitconfig'` you can say
> `get_option('sysconfdir') / 'gitconfig'`. It's a bit pointless in this
> case and not really needed, but '/' has some special magic for handling
> absolute and relative paths.

OK, TIL. I just looked this up ([0]) and I am not sure such 'magic' is
always a good thing. ;)

[0] https://mesonbuild.com/Syntax.html#string-path-building

>> +endif
>>  editor_opt = get_option('default_editor')
>>  if editor_opt != '' and editor_opt != 'vi'
>>    libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"'
> 
> Nit: let's maybe add an empty newline after each of these blocks to make
> it a bit easier to see where handling for each specific option stops.

OK, will do.

>> diff --git a/meson_options.txt b/meson_options.txt
>> index 8547c0eb47..4d78d4c7ac 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -3,9 +3,9 @@ option('default_pager', type: 'string', value: 'less',
>>    description: 'Fall-back pager.')
>>  option('default_editor', type: 'string', value: 'vi',
>>    description: 'Fall-back editor.')
>> -option('gitconfig', type: 'string', value: '/etc/gitconfig',
>> +option('gitconfig', type: 'string',
>>    description: 'Path to the global git configuration file.')
>> -option('gitattributes', type: 'string', value: '/etc/gitattributes',
>> +option('gitattributes', type: 'string',
>>    description: 'Path to the global git attributes file.')
>>  option('pager_environment', type: 'string', value: 'LESS=FRX LV=-c',
>>    description: 'Environment used when spawning the pager')
> 
> Makes sense. Should we maybe document the default values here now that
> they aren't immediately obvious anymore?

good idea.

Thanks!

ATB,
Ramsay Jones






[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