Skip to content

Commit

Permalink
show that HEAD's referent also has the correct reflog (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 19, 2022
1 parent 1e7fd4e commit c25cb00
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions git-repository/tests/clone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ mod blocking_io {
let head = repo.head()?;
{
let mut logs = head.log_iter();
let head_logs = logs.all()?.expect("log present").collect::<Result<Vec<_>, _>>()?;
assert_eq!(head_logs.len(), 1, "just created");
let line = &head_logs[0];
assert!(line.message.starts_with(b"clone: from "), "{:?} unexpected", line);
let path = git_path::from_bstr(line.message.rsplit(|b| *b == b' ').next().expect("path").as_bstr());
assert!(path.is_absolute(), "{:?} must be absolute", path);
assert_reflog(logs.all());
}

let referent = head.try_into_referent().expect("symbolic ref is present");
Expand All @@ -96,9 +91,27 @@ mod blocking_io {
remote::repo("base").head_name()?.expect("symbolic").as_bstr(),
"local clone always adopts the name of the remote"
);

{
let mut logs = referent.log_iter();
assert_reflog(logs.all());
}
Ok(())
}

fn assert_reflog(logs: std::io::Result<Option<git_ref::file::log::iter::Forward<'_>>>) {
let logs = logs
.unwrap()
.expect("log present")
.collect::<Result<Vec<_>, _>>()
.unwrap();
assert_eq!(logs.len(), 1, "just created");
let line = &logs[0];
assert!(line.message.starts_with(b"clone: from "), "{:?} unexpected", line);
let path = git_path::from_bstr(line.message.rsplit(|b| *b == b' ').next().expect("path").as_bstr());
assert!(path.is_absolute(), "{:?} must be absolute", path);
}

#[test]
fn fetch_and_checkout() -> crate::Result {
let tmp = git_testtools::tempfile::TempDir::new()?;
Expand Down

0 comments on commit c25cb00

Please sign in to comment.