Skip to content

Commit c6abbaf

Browse files
author
Stephan Dilly
authored
fix hirarchical branch names (#931)
1 parent 8596e01 commit c6abbaf

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- support rebasing branches with conflicts ([#895](https://github.com/extrawurst/gitui/issues/895))
1212

1313
## Fixed
14-
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/991))
14+
- fix supported checkout of hierarchical branchnames ([#921](https://github.com/extrawurst/gitui/issues/921))
15+
- appropriate error message when pulling deleted remote branch ([#911](https://github.com/extrawurst/gitui/issues/911))
1516
- improved color contrast in branches popup for light themes [[@Cottser](https://github.com/Cottser)] ([#922](https://github.com/extrawurst/gitui/issues/922))
1617
- use git_message_prettify for commit messages ([#917](https://github.com/extrawurst/gitui/issues/917))
1718

asyncgit/src/sync/branch/mod.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pub fn checkout_remote_branch(
319319
return Err(Error::UncommittedChanges);
320320
}
321321

322-
let name = branch.name.rfind('/').map_or_else(
322+
let name = branch.name.find('/').map_or_else(
323323
|| branch.name.clone(),
324324
|pos| branch.name[pos..].to_string(),
325325
);
@@ -795,6 +795,52 @@ mod test_remote_branches {
795795
assert_eq!(&get_branch_name(clone2_dir).unwrap(), "foo");
796796
}
797797

798+
#[test]
799+
fn test_checkout_remote_branch_hirachical() {
800+
let (r1_dir, _repo) = repo_init_bare().unwrap();
801+
802+
let (clone1_dir, clone1) =
803+
repo_clone(r1_dir.path().to_str().unwrap()).unwrap();
804+
let clone1_dir = clone1_dir.path().to_str().unwrap();
805+
806+
// clone1
807+
808+
let branch_name = "bar/foo";
809+
810+
write_commit_file(&clone1, "test.txt", "test", "commit1");
811+
push(
812+
clone1_dir, "origin", "master", false, false, None, None,
813+
)
814+
.unwrap();
815+
create_branch(clone1_dir, branch_name).unwrap();
816+
write_commit_file(&clone1, "test.txt", "test2", "commit2");
817+
push(
818+
clone1_dir,
819+
"origin",
820+
branch_name,
821+
false,
822+
false,
823+
None,
824+
None,
825+
)
826+
.unwrap();
827+
828+
// clone2
829+
830+
let (clone2_dir, _clone2) =
831+
repo_clone(r1_dir.path().to_str().unwrap()).unwrap();
832+
let clone2_dir = clone2_dir.path().to_str().unwrap();
833+
834+
let branches = get_branches_info(clone2_dir, false).unwrap();
835+
836+
checkout_remote_branch(clone2_dir, &branches[1]).unwrap();
837+
838+
assert_eq!(
839+
&get_branch_name(clone2_dir).unwrap(),
840+
branch_name
841+
);
842+
}
843+
798844
#[test]
799845
fn test_has_tracking() {
800846
let (r1_dir, _repo) = repo_init_bare().unwrap();

0 commit comments

Comments
 (0)