Bug 581875 - JGit doesnt resolve the same configuration files
Summary: JGit doesnt resolve the same configuration files
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.5   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 6.7   Edit
Assignee: Thomas Wolf CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 430194 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-04-28 05:04 EDT by Norbert Lange CLA
Modified: 2023-08-29 18:30 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Norbert Lange CLA 2023-04-28 05:04:13 EDT
There are already multiple issues, first a quote from the git docs:

----- https://git-scm.com/docs/git-config

--global
For writing options: write to global ~/.gitconfig file rather than the repository .git/config, write to $XDG_CONFIG_HOME/git/config file if this file exists and the ~/.gitconfig file doesn’t.

For reading options: read only from global ~/.gitconfig and from $XDG_CONFIG_HOME/git/config rather than from all available files.

--system
For writing options: write to system-wide $(prefix)/etc/gitconfig rather than the repository .git/config.

For reading options: read only from system-wide $(prefix)/etc/gitconfig rather than from all available files.

-----

Now onto the issues:

-   $XDG_CONFIG_HOME/git/config is not read by JGit
-   $XDG_CONFIG_HOME/git/config is never written to by JGit
-   On Windows, the system configuration `%ProgramFiles%\Git\etc\gitconfig` is never used

Which then results in missing/wrong configuration.
Comment 1 Thomas Wolf CLA 2023-06-12 04:43:48 EDT
*** Bug 430194 has been marked as a duplicate of this bug. ***
Comment 2 Matthias Sohn CLA 2023-08-29 17:04:32 EDT
https://git.eclipse.org/r/c/jgit/jgit/+/203248 merged as a2f326b76200c8def03eb136811c2cb5bc304f89
Comment 3 Thomas Wolf CLA 2023-08-29 18:30:09 EDT
To clarify: that change solves respecting $XDG_CONFIG_HOME/git/config.

About the system config on Windows: if git.exe is on the %PATH%, it should be used. (JGit uses the native git to detect where the system config is. If JGit cannot find the git executable, it also cannot find the system config.)