Repository: gitui-org/gitui (language: rust)

Issue:
[BUG]: Does not support custom git config path via GIT_CONFIG_GLOBAL
**Describe the bug**
I tried to commit some changes and got the following error

```
commit error:
git error:config value 'user.name' was not found; class=Config (7); code=NotFound (-3)
```

It turns out it cannot find `user.name` or any other config because I have my git configuration in a different path from `~/.gitconfig`, which I achieved by setting `GIT_CONFIG_GLOBAL` to `~/.config/git/config.ini`.

**To Reproduce**
Steps to reproduce the behavior:
1. `export GIT_CONFIG_GLOBAL=~/.config/git/config.ini` (or any other location)
2. Go to a git repository and make some changes
3. Commit through `gitui`
4. See error

**Expected behavior**
It should check for this environment variable and use it if set.
Also there is another environment variable that is related: `GIT_CONFIG_SYSTEM`.

**Workaround**
```bash
ln -s $GIT_CONFIG_GLOBAL ~/.gitconfig
```

**Context (please complete the following information):**
 - OS/Distro + Version: `Fedora Linux 40`
 - GitUI Version: `gitui 0.26.3 2024-06-02 ()`
 - Rust version: NA (installed through `dnf`)




Discussion / hints:
That is interesting. upstream supports this since last year: https://github.com/libgit2/libgit2/pull/6544

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 630cf520d6..7c24f38357 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## Unreleased
 
+### Fixes
+* respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/extrawurst/gitui/issues/2298))
+
 ## [0.26.3] - 2024-06-02
 
 ### Breaking Changes
diff --git a/asyncgit/src/sync/repository.rs b/asyncgit/src/sync/repository.rs
index 24620d4cbf..2a0af47dbd 100644
--- a/asyncgit/src/sync/repository.rs
+++ b/asyncgit/src/sync/repository.rs
@@ -51,7 +51,7 @@ impl From<&str> for RepoPath {
 pub fn repo(repo_path: &RepoPath) -> Result<Repository> {
 	let repo = Repository::open_ext(
 		repo_path.gitpath(),
-		RepositoryOpenFlags::empty(),
+		RepositoryOpenFlags::FROM_ENV,
 		Vec::<&Path>::new(),
 	)?;
 
diff --git a/asyncgit/src/sync/submodules.rs b/asyncgit/src/sync/submodules.rs
index b69dde36d7..f984ac0b19 100644
--- a/asyncgit/src/sync/submodules.rs
+++ b/asyncgit/src/sync/submodules.rs
@@ -123,7 +123,7 @@ pub fn submodule_parent_info(
 
 		if let Ok(parent) = Repository::open_ext(
 			parent_path,
-			RepositoryOpenFlags::empty(),
+			RepositoryOpenFlags::FROM_ENV,
 			Vec::<&Path>::new(),
 		) {
 			let parent_wd = work_dir(&parent)?.to_path_buf();
diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs
index a5ec1b3e9b..3e31359799 100644
--- a/asyncgit/src/sync/utils.rs
+++ b/asyncgit/src/sync/utils.rs
@@ -28,7 +28,7 @@ pub struct Head {
 pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
 	Repository::open_ext(
 		repo_path.gitpath(),
-		RepositoryOpenFlags::empty(),
+		RepositoryOpenFlags::FROM_ENV,
 		Vec::<&Path>::new(),
 	)
 	.map_or_else(|e| Some(e.to_string()), |_| None)


Test patch: