Skip to content

Commit

Permalink
refactor: deduce path from repo for GitCheckout
Browse files Browse the repository at this point in the history
It was confusing and may lead to inconsistency that people need to
pass both `path` and `repo` and ensure they are in sync.
  • Loading branch information
weihanglo committed May 30, 2023
1 parent 45e3a86 commit 9baf0c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl GitDatabase {
// clone is created.
let checkout = match git2::Repository::open(dest)
.ok()
.map(|repo| GitCheckout::new(dest, self, rev, repo))
.map(|repo| GitCheckout::new(self, rev, repo))
.filter(|co| co.is_fresh())
{
Some(co) => co,
Expand Down Expand Up @@ -265,13 +265,13 @@ impl<'a> GitCheckout<'a> {
/// is done. Use [`GitCheckout::is_fresh`] to check.
///
/// * The `database` is where this checkout is from.
/// * The `repo` will be the checked out Git repoistory at `path`.
/// * The `repo` will be the checked out Git repoistory.
fn new(
path: &Path,
database: &'a GitDatabase,
revision: git2::Oid,
repo: git2::Repository,
) -> GitCheckout<'a> {
let path = repo.workdir().unwrap_or_else(|| repo.path());
GitCheckout {
path: path.to_path_buf(),
database,
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<'a> GitCheckout<'a> {
})?;
let repo = repo.unwrap();

let checkout = GitCheckout::new(into, database, revision, repo);
let checkout = GitCheckout::new(database, revision, repo);
checkout.reset(config)?;
Ok(checkout)
}
Expand Down

0 comments on commit 9baf0c8

Please sign in to comment.