gitui icon indicating copy to clipboard operation
gitui copied to clipboard

user.name was not found for .gitconfig with includeIf

Open mloskot opened this issue 2 years ago • 9 comments

I use a peculiar .gitconfig with numerous includeIf directives and it works well with git and Fork and GitHub Desktop, as well as with lazygit:

$ git config --get user.name
Mateusz Łoskot
$ git config --get user.email
[email protected]

I'm also using export GPG_TTY=$(tty) and signing my commits using terminal-based passphrase prompt.

I've just tried gitui on Ubuntu 22.04 and it seems tripping over my special Git configuration, complaining with:

commit error:
git error:config value 'user.name' was not found; class=Config (7); code=NotFound (-3)

I've searched around and I found this about gitui not using git cli, https://github.com/extrawurst/gitui/issues/74#issuecomment-631522799, so I assume it does not rely on git-native processing of .gitconfig. This may explain it may be tripping over includeIf indeed.

mloskot avatar May 19 '23 17:05 mloskot

gitui does not use the git cli underneath but it does use libgit2 which does support includeif, so it should work.

is the config file you show the one that failed? Could you please run gitui -l to produce a log file. Te log will be here

  • using XDG: $XDG_CACHE_HOME/gitui/gitui.log
  • $HOME/.cache/gitui/gitui.log otherwise

pm100 avatar May 21 '23 20:05 pm100

is the config file you show the one that failed?

Yes, this is my .gitconfig with includeIf-s.

Could you please run gitui -l to produce a log file

Of course, here is my $HOME/.cache/gitui/gitui.log: gitui.log

I use gitui 0.22.1 in Ubuntu 22.04 (on WLS).

mloskot avatar May 21 '23 20:05 mloskot

OK, this i complicated issue caused by a bug in libgit2. Your use of %(prefix) is what is causing the error. The temporatry solution is to duplicate the includeifs that you need to use with gitui. I tested this

[user]
    name="test"
[includeIf "gitdir:%(prefix)//Users/pm100/**"]
	path = %(prefix)//Users/pm100/mygit
[includeIf "gitdir:/Users/pm100/**"]
	path = /Users/pm100/mygit  

and it works fine. libgit should be ignoring the %(prefix) in the non windows (non WSL too) case but it is not (they comment that they should but forget to do it)

pm100 avatar May 22 '23 09:05 pm100

I've applied the workaround and it works for me too - thank you!

@pm100 Shall I close this issue or keep it open and waiting for libgit2 fix?

mloskot avatar May 22 '23 13:05 mloskot

@mloskot leave it open please, useful for tracking the libgit issue

https://github.com/libgit2/libgit2/issues/6566

pm100 avatar May 23 '23 06:05 pm100

@mloskot I also suspect that running the windows binary under wsl would work, although people have repoerted that this is slow to load in WSL

pm100 avatar May 23 '23 14:05 pm100

@pm100 running gitui.exe under WSL is failing for me with a new kind of issue

image

A side note regarding the libgit2 bug, interestingly the %(prefix)-less workaround from https://github.com/extrawurst/gitui/issues/1696#issuecomment-1556867860 is upsetting lazygit

image

mloskot avatar May 23 '23 15:05 mloskot

@mloskot windows binary runs for me but behaves oddly :-( , it was worth a shot

pm100 avatar May 23 '23 16:05 pm100

@pm100 Yeah, it was. Testing is what I can only offer for now - I can't speak any Rust, yet. Thank for help!

mloskot avatar May 23 '23 16:05 mloskot