Skip to content

Commit

Permalink
validate that the remote HEAD branch overrides local init.defaultBran…
Browse files Browse the repository at this point in the history
…ch settings (#450)
  • Loading branch information
Byron committed Oct 19, 2022
1 parent 5d7a055 commit 1c3dd3a
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions git-repository/tests/clone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ mod blocking_io {
let tmp = git_testtools::tempfile::TempDir::new()?;
let called_configure_remote = std::sync::Arc::new(std::sync::atomic::AtomicBool::default());
let remote_name = "special";
let mut prepare = git::prepare_clone_bare(remote::repo("base").path(), tmp.path())?
.with_remote_name(remote_name)?
.configure_remote({
let called_configure_remote = called_configure_remote.clone();
move |r| {
called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed);
Ok(
r.with_refspec("+refs/tags/*:refs/tags/*", git::remote::Direction::Fetch)
.expect("valid static spec"),
)
}
});
let mut prepare = git::clone::PrepareFetch::new(
remote::repo("base").path(),
tmp.path(),
git::create::Kind::Bare,
Default::default(),
git::open::Options::isolated().config_overrides(Some("init.defaultBranch=unused-as-overridden-by-remote")),
)?
.with_remote_name(remote_name)?
.configure_remote({
let called_configure_remote = called_configure_remote.clone();
move |r| {
called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed);
Ok(
r.with_refspec("+refs/tags/*:refs/tags/*", git::remote::Direction::Fetch)
.expect("valid static spec"),
)
}
});
let (repo, out) = prepare.fetch_only(git::progress::Discard, &std::sync::atomic::AtomicBool::default())?;
drop(prepare);

Expand Down Expand Up @@ -71,6 +77,11 @@ mod blocking_io {
referent.id().object().is_ok(),
"the object pointed to by HEAD was fetched as well"
);
assert_eq!(
referent.name().as_bstr(),
remote::repo("base").head_name()?.expect("symbolic").as_bstr(),
"local clone always adopts the name of the remote"
);
Ok(())
}

Expand Down

0 comments on commit 1c3dd3a

Please sign in to comment.