mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge pull request #12331 from DeterminateSystems/git-dir
GitRepo::fetch(): Ignore $GIT_DIR
This commit is contained in:
commit
64a38992da
3 changed files with 18 additions and 8 deletions
|
@ -206,7 +206,8 @@ static git_packbuilder_progress PACKBUILDER_PROGRESS_CHECK_INTERRUPT = &packBuil
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
static void initRepoAtomically(std::filesystem::path &path, bool bare) {
|
static void initRepoAtomically(std::filesystem::path &path, bool bare)
|
||||||
|
{
|
||||||
if (pathExists(path.string())) return;
|
if (pathExists(path.string())) return;
|
||||||
|
|
||||||
Path tmpDir = createTempDir(os_string_to_string(PathViewNG { std::filesystem::path(path).parent_path() }));
|
Path tmpDir = createTempDir(os_string_to_string(PathViewNG { std::filesystem::path(path).parent_path() }));
|
||||||
|
@ -544,13 +545,10 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
// then use code that was removed in this commit (see blame)
|
// then use code that was removed in this commit (see blame)
|
||||||
|
|
||||||
auto dir = this->path;
|
auto dir = this->path;
|
||||||
Strings gitArgs;
|
Strings gitArgs{"-C", dir.string(), "--git-dir", ".", "fetch", "--quiet", "--force"};
|
||||||
if (shallow) {
|
if (shallow)
|
||||||
gitArgs = { "-C", dir.string(), "fetch", "--quiet", "--force", "--depth", "1", "--", url, refspec };
|
append(gitArgs, {"--depth", "1"});
|
||||||
}
|
append(gitArgs, {std::string("--"), url, refspec});
|
||||||
else {
|
|
||||||
gitArgs = { "-C", dir.string(), "fetch", "--quiet", "--force", "--", url, refspec };
|
|
||||||
}
|
|
||||||
|
|
||||||
runProgram(RunOptions {
|
runProgram(RunOptions {
|
||||||
.program = "git",
|
.program = "git",
|
||||||
|
|
|
@ -274,6 +274,17 @@ std::optional<typename T::value_type> pop(T & c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append items to a container. TODO: remove this once we can use
|
||||||
|
* C++23's `append_range()`.
|
||||||
|
*/
|
||||||
|
template<class C, typename T>
|
||||||
|
void append(C & c, std::initializer_list<T> l)
|
||||||
|
{
|
||||||
|
c.insert(c.end(), l.begin(), l.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Callback;
|
class Callback;
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ unset XDG_DATA_HOME
|
||||||
unset XDG_CONFIG_HOME
|
unset XDG_CONFIG_HOME
|
||||||
unset XDG_CONFIG_DIRS
|
unset XDG_CONFIG_DIRS
|
||||||
unset XDG_CACHE_HOME
|
unset XDG_CACHE_HOME
|
||||||
|
unset GIT_DIR
|
||||||
|
|
||||||
export IMPURE_VAR1=foo
|
export IMPURE_VAR1=foo
|
||||||
export IMPURE_VAR2=bar
|
export IMPURE_VAR2=bar
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue