Skip to content

Commit ea22be3

Browse files
Add regression tests for Remote::list() with an empty list
Test currently fails in debug builds with unsafe preconditions of `slice::from_raw_parts()` being violated, in release builds it currently passes but relies on undefined behavior.
1 parent 8aeb3ef commit ea22be3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/remote.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,20 @@ mod tests {
921921
drop(origin.clone());
922922
}
923923

924+
#[test]
925+
fn empty_remote_list() {
926+
// Regression tests for issue #1217
927+
let td = TempDir::new().unwrap();
928+
let repo = Repository::init(td.path()).unwrap();
929+
930+
let remote_dir = TempDir::new().unwrap();
931+
let _remote_repo = Repository::init_bare(remote_dir.path()).unwrap();
932+
let remote_url = format!("file://{}", remote_dir.path().display());
933+
let mut remote = repo.remote("origin", &remote_url).unwrap();
934+
remote.connect(Direction::Fetch).unwrap();
935+
assert_eq!(0, remote.list().unwrap().len());
936+
}
937+
924938
#[test]
925939
fn is_valid_name() {
926940
assert!(Remote::is_valid_name("foobar"));

0 commit comments

Comments
 (0)