Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Panic when filename of staged file contains non-ASCII character #384

@5hir0kur0

Description

@5hir0kur0

Description

In some situations with non-ASCII file names, gitu panics.

Reproduction

  1. Check out master branch (tested with commit 5dbf6ed).
  2. Run the following shell commands
touch 'bläh'
git add 'bläh'
RUST_BACKTRACE=1 cargo -q run 2>err; echo "exit code: $?; error:"; cat err

The following panic backtrace is printed:

exit code: 101; error:

thread 'main' panicked at src/git/mod.rs:156:64:
called `Result::unwrap()` on an `Err` value: Expected "<diff header path prefix (' a/...' or ' b/...')>" at byte 11
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
   1: core::panicking::panic_fmt
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
   2: core::result::unwrap_failed
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/result.rs:1704:5
   3: core::result::Result<T,E>::unwrap
             at ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
   4: gitu::git::diff_staged
             at ./src/git/mod.rs:156:21
   5: gitu::screen::status::create::{{closure}}
             at ./src/screen/status.rs:94:26
   6: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2007:9
   7: gitu::screen::Screen::update
             at ./src/screen/mod.rs:208:22
   8: gitu::screen::Screen::new
             at ./src/screen/mod.rs:58:9
   9: gitu::screen::status::create
             at ./src/screen/status.rs:18:5
  10: gitu::state::State::create
             at ./src/state.rs:76:26
  11: gitu::run
             at ./src/lib.rs:83:21
  12: gitu::main
             at ./src/main.rs:34:5
  13: core::ops::function::FnOnce::call_once
             at ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions