Open 03juan opened 2 weeks ago
Thanks a lot for reporting!
I took a quick look and it seems like we are only asking the Git configuration for user information. This is usually correct enough.
Could you help me understand how /home/juan/.config/git/config
is included? My feeling is that git2
somehow doesn't see this file, maybe because it doesn't follow (conditional) includes.
That file is being picked up because $XDG_CONFIG_HOME
is set in my environment, so git picks that up along with ~/.gitconfig
as part of the global config.
FILES By default, git config will read configuration options from multiple files:
$(prefix)/etc/gitconfig System-wide configuration file. $XDG_CONFIG_HOME/git/config, ~/.gitconfig User-specific configuration files. When the XDG_CONFIG_HOME environment variable is not set or empty, $HOME/.config/ is used as $XDG_CONFIG_HOME.
man git-config
$ env | grep XDG
XDG_RUNTIME_DIR=/run/user/1000/
XDG_CONFIG_HOME=/home/juan/.config
XDG_CACHE_HOME=/home/juan/.cache
XDG_DATA_HOME=/home/juan/.local/share
As a test I also set user.name
and user.email
in the local config
$ git config --show-origin --show-scope --get-all user.email
global file:/home/juan/.config/git/config 4416345+03juan@users.noreply.github.com
local file:.git/config 4416345+03juan@users.noreply.github.com
$ git config --show-origin --show-scope --get-all user.name
global file:/home/juan/.config/git/config Juan P Barrios
local file:.git/config Juan P Barrios
But still got the error after restarting git-butler
from the same command line.
STDERR: remote: error: GH007: Your push would publish a private email address. remote: You can make your email public or disable this protection by visiting: remote: http://github.com/settings/emails To https://github.com/03juan/ms_interface ! [remote rejected] a2c88c2f11902afe966ece77d4ee4042d5a1cfba -> test-push-1720023956647 (push declined due to email privacy restrictions)
As a test I also set
user.name
anduser.email
in the local config
That's a great idea! And it's shocking that despite local scope the setting is still not picked up when creating a commit. Looking into this further, fortunately I think I found the culprit.
get_user()
is called whenever a commit in a virtual branch is created, and it overrides getting credentials from the configuration.
That User
struct has separate name
and email
fields which are then used in the commit.
I am going to CC @krlvi here as changing it would be easy, but it's also changing something that was probably done for a reason.
Great news. Glad you managed to hone in on the potential culprit! 🔥
Issue
Testing the Git authentication on a new GB Project fails with the default "Use a Git executable" option as the commit is pushed with my GB profile's email address, instead of the one set in my global git configuration.
This is related to the GH email setting "Block command line pushes that expose my email".
Additional context
I have the gh CLI set up as a credential helper
Choosing "Use a Git credentials helper" also doesn't work
Related
https://github.com/gitbutlerapp/gitbutler/issues/2883#issuecomment-1961995720_