Skip to content

Commit

Permalink
fix path handling on windows (gitui-org#762)
Browse files Browse the repository at this point in the history
* this reduces memory overhead where nothing is folded up
* makes folding work with windows path seperators
  • Loading branch information
Stephan Dilly authored and Rémi Garde committed Jun 16, 2021
1 parent 0e7ac4a commit 3fcf157
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 155 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Fixed
- wrong file with same name shown in file tree ([#748](https://github.com/extrawurst/gitui/issues/748))
- filetree collapsing broken on windows ([#761](https://github.com/extrawurst/gitui/issues/761))

### Internal
- use git_repository_message [[@kosayoda](https://github.com/kosayoda)] ([#751](https://github.com/extrawurst/gitui/issues/751))
Expand Down
10 changes: 9 additions & 1 deletion asyncgit/src/sync/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ pub fn blame_file(

let commit_id = utils::get_head_repo(&repo)?;

let spec = format!("{}:{}", commit_id.to_string(), file_path);
let spec = if cfg!(unix) {
format!("{}:{}", commit_id.to_string(), file_path)
} else {
format!(
"{}:{}",
commit_id.to_string(),
file_path.replace("\\", "/")
)
};

let object = repo.revparse_single(&spec)?;
let blob = repo.find_blob(object.id())?;
Expand Down
3 changes: 0 additions & 3 deletions filetreelist/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ pub enum Error {
#[error("InvalidPath: `{0}`")]
InvalidPath(PathBuf),

#[error("InvalidFilePath: `{0}`")]
InvalidFilePath(String),

#[error("TryFromInt error:{0}")]
IntConversion(#[from] TryFromIntError),
}
Expand Down
34 changes: 17 additions & 17 deletions filetreelist/src/filetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
error::Result, filetreeitems::FileTreeItems,
tree_iter::TreeIterator, TreeItemInfo,
};
use std::{collections::BTreeSet, usize};
use std::{collections::BTreeSet, path::Path, usize};

///
#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -35,7 +35,7 @@ pub struct FileTree {
impl FileTree {
///
pub fn new(
list: &[&str],
list: &[&Path],
collapsed: &BTreeSet<&String>,
) -> Result<Self> {
let mut new_self = Self {
Expand Down Expand Up @@ -318,12 +318,12 @@ impl FileTree {
mod test {
use crate::{FileTree, MoveSelection};
use pretty_assertions::assert_eq;
use std::collections::BTreeSet;
use std::{collections::BTreeSet, path::Path};

#[test]
fn test_selection() {
let items = vec![
"a/b", //
Path::new("a/b"), //
];

let mut tree =
Expand All @@ -341,8 +341,8 @@ mod test {
#[test]
fn test_selection_skips_collapsed() {
let items = vec![
"a/b/c", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/d"), //
];

//0 a/
Expand All @@ -364,8 +364,8 @@ mod test {
#[test]
fn test_selection_left_collapse() {
let items = vec![
"a/b/c", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/d"), //
];

//0 a/
Expand All @@ -390,8 +390,8 @@ mod test {
#[test]
fn test_selection_left_parent() {
let items = vec![
"a/b/c", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/d"), //
];

//0 a/
Expand All @@ -417,8 +417,8 @@ mod test {
#[test]
fn test_selection_right_expand() {
let items = vec![
"a/b/c", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/d"), //
];

//0 a/
Expand Down Expand Up @@ -449,8 +449,8 @@ mod test {
#[test]
fn test_selection_top() {
let items = vec![
"a/b/c", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/d"), //
];

//0 a/
Expand All @@ -470,9 +470,9 @@ mod test {
#[test]
fn test_visible_selection() {
let items = vec![
"a/b/c", //
"a/b/c2", //
"a/d", //
Path::new("a/b/c"), //
Path::new("a/b/c2"), //
Path::new("a/d"), //
];

//0 a/
Expand Down
Loading

0 comments on commit 3fcf157

Please sign in to comment.