gitu
gitu copied to clipboard
Panic when filename of staged file contains non-ASCII character
Description
In some situations with non-ASCII file names, gitu panics.
Reproduction
- Check out
masterbranch (tested with commit 5dbf6ed). - 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.
Same panic with diff.noprefix=true in /etc/gitconfig by the way..
Got this when trying to open my music folder (git-annex)
trace:
0: gitu::main::{{closure}}
1: std::panicking::rust_panic_with_hook
2: std::panicking::begin_panic_handler::{{closure}}
3: std::sys::backtrace::__rust_end_short_backtrace
4: rust_begin_unwind
5: core::panicking::panic_fmt
6: core::result::unwrap_failed
7: gitu::git::diff_staged
8: gitu::screen::status::create::{{closure}}
9: gitu::screen::Screen::update
10: gitu::screen::Screen::new
11: gitu::screen::status::create
12: gitu::run
13: gitu::setup_term_and_run
14: gitu::term::alternate_screen
15: gitu::main
16: std::sys::backtrace::__rust_begin_short_backtrace
17: std::rt::lang_start::{{closure}}
18: std::rt::lang_start_internal
19: main
20: __libc_start_call_main
21: __libc_start_main_alias_1
22: _start
``
All of these issues should be fixed in https://github.com/altsem/gitu/commit/e40cfc8870168b70cee6d32c32ea5e7086fac42e.
I noted that diffs without a prefix are not possible to feed back into git (when e.g. staging), so that remains to figure out.