Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/screen/show_refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ fn create_remotes_sections<'a>(repo: &'a Repository) -> Res<impl Iterator<Item =
let all_remotes = create_reference_items(repo, Reference::is_remote)?;
let mut remotes = BTreeMap::new();
for (name, remote) in all_remotes {
let name =
String::from_utf8_lossy(&repo.branch_remote_name(&name).map_err(Error::GetRemote)?)
.to_string();
// A remote-tracking ref can exist without a configured remote (for
// example a leftover ref from a conflicted rebase). Skip those instead
// of failing the whole screen.
let Ok(remote_name) = repo.branch_remote_name(&name) else {
continue;
};
let name = String::from_utf8_lossy(&remote_name).to_string();

match remotes.entry(name) {
Entry::Vacant(entry) => {
Expand Down
15 changes: 15 additions & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,21 @@ mod show_refs {
run(&ctx.dir, &["git", "tag", "v1.0"]);
snapshot!(ctx, "Yjjjjjjbb<enter>Y");
}

#[test]
fn show_refs_with_remote_tracking_ref_without_remote() {
let ctx = setup_clone!();
run(
&ctx.dir,
&[
"git",
"update-ref",
"refs/remotes/conflict-upstream/main",
"HEAD",
],
);
snapshot!(ctx, "Y");
}
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: src/tests/mod.rs
expression: ctx.redact_buffer()
---
▌Branches |
▌* main |
|
Remote origin |
origin/HEAD |
origin/main |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
styles_hash: 23e139cddc801205