Repository: starship/starship
File: src/test/mod.rs (Rust)

Code before:
            // This is especially important on Windows.
            // Newer, more far-reaching git setting for `fsync`, that's not yet widely supported:
            create_command("git")?
                .args(["config", "--local", "core.fsync", "all"])
                .current_dir(path.path())
                .output()?;

            // Older git setting for `fsync` for compatibility with older git versions:
            create_command("git")?
                .args(["config", "--local", "core.fsyncObjectFiles", "true"])
                .current_dir(path.path())
                .output()?;

            create_command("git")?
                .args(["reset", "--hard", "HEAD"])
                .current_dir(path.path())
                .output()?;

            Ok(path)
        }
        FixtureProvider::GitBare => {
            let path = tempfile::tempdir()?;
            create_command("git")?
                .current_dir(path.path())
                .args(["--bare", "init"])
                .output()?;
            Ok(path)
        }
        FixtureProvider::Hg => {
            let path = tempfile::tempdir()?;

            create_command("hg")?
                .current_dir(path.path())
                .arg("clone")
                .arg(HG_FIXTURE.as_os_str())
                .arg(path.path())
                .output()?;

            Ok(path)
        }
        FixtureProvider::Pijul => {
            let path = tempfile::tempdir()?;
            fs::create_dir(path.path().join(".pijul"))?;
            Ok(path)
        }
    }
}


Review comment (suggestion):
I think this should use `gix::ThreadSafeRepository::init` instead.

Code after:
            // This is especially important on Windows.
            // Newer, more far-reaching git setting for `fsync`, that's not yet widely supported:
            create_command("git")?
                .args(["config", "--local", "core.fsync", "all"])
                .current_dir(path.path())
                .output()?;

            // Older git setting for `fsync` for compatibility with older git versions:
            create_command("git")?
                .args(["config", "--local", "core.fsyncObjectFiles", "true"])
                .current_dir(path.path())
                .output()?;

            create_command("git")?
                .args(["reset", "--hard", "HEAD"])
                .current_dir(path.path())
                .output()?;

            Ok(path)
        }
        FixtureProvider::GitBare => {
            let path = tempfile::tempdir()?;
            gix::ThreadSafeRepository::init(
                &path,
                gix::create::Kind::Bare,
                gix::create::Options::default(),
            )
            .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
            Ok(path)
        }
        FixtureProvider::Hg => {
            let path = tempfile::tempdir()?;

            create_command("hg")?
                .current_dir(path.path())
                .arg("clone")
                .arg(HG_FIXTURE.as_os_str())
                .arg(path.path())
                .output()?;

            Ok(path)
        }
        FixtureProvider::Pijul => {
            let path = tempfile::tempdir()?;
            fs::create_dir(path.path().join(".pijul"))?;
            Ok(path)
        }
    }
}