Re: How to properly find git config in a libgit.a-using executable?

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

 



On Wed, Mar 20, 2019 at 07:19:41PM +0900, Mike Hommey wrote:

> I thought of a few options (it's worth noting the helper is invoked in a
> way that makes $GIT_EXEC_PATH set, which can help a little):
> - spawn `$GIT_EXEC_PATH/git-config -l -z`, parse its output, and set the
>   internal config from that. That's the barbarian option.
> - build the helper with RUNTIME_PREFIX, and modify the RUNTIME_PREFIX
>   code to use $GIT_EXEC_PATH if it's set, rather than the path the
>   executable is in. That actually sounds reasonable enough that I'd send
>   a patch for git itself. But that doesn't quite address the nitpick case
>   where ETC_GITCONFIG could be either `/etc/gitconfig` or
>   `etc/gitconfig` depending how git was compiled, and there's no way to
>   know which is the right one.

I'm not entirely sure I understand the problem, but it sounds like you
want to know the baked-in ETC_GITCONFIG for a built version of git (that
isn't necessarily the one that shares your build of libgit.a).

There's no direct way to have Git print that out. It would be reasonable
to add one to rev-parse, I think.

Barring that, here's a hack:

  git config --system --show-origin --list -z |
  perl -lne '/^file:(.*?)\0/ and print $1 and exit 0'

If the file is empty, it won't print anything, of course. But then,
you'd know that it also has no config in it. :)

-Peff



[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