libfetchers: Provide gitDir for rev-list operation

Without the `--git-dir` git will attempt to figure out which the git directory is on its own.
This causes issues when the `GIT_DIR` envvar is set in the environment for other reasons (such as being part of a `git rebase`).
Providing this parameter overrides the environment and thus makes sure the revs are always coming from the intended repository.

Fixes: #1135
Change-Id: Ibd43cfd8e0278463c0e1ccf86779982947a6038a
Signed-off-by: benaryorg <binary@benary.org>
This commit is contained in:
benaryorg
2026-02-28 09:06:18 +00:00
committed by Katze
parent dda934965d
commit 052d04512e
+1 -1
View File
@@ -833,7 +833,7 @@ struct GitInputScheme : InputScheme
auto rev = chomp(TRY_AWAIT(runProgram(
"git",
true,
{"-C", repoDir, "rev-list", "--max-count=1", *input.getRef()}
{"-C", repoDir, "--git-dir", gitDir, "rev-list", "--max-count=1", *input.getRef()}
)));
input.attrs.insert_or_assign("rev", rev);
}