gitu icon indicating copy to clipboard operation
gitu copied to clipboard

Panic on Merge-Conflict Diff

Open the-kenny opened this issue 8 months ago • 2 comments

Might be similar to #343 but isn't caused by the no newline at end of file:

Example 1

panicked at src/git/mod.rs:155:64:
called `Result::unwrap()` on an `Err` value: ParseError { input: "diff --git a/src/config.rs b/src/config.rs\nindex a22a438..095d9c7 100644\n--- a/src/config.rs\n+++ b/src/config.rs\n@@ -15,6 +15,7 @@ const DEFAULT_CONFIG: &str = include_str!(\"default_config.toml\");\n pub(crate) struct Config {\n     pub general: GeneralConfig,\n     pub style: StyleConfig,\n+    pub editor: EditorConfig,\n     pub bindings: BTreeMap<Menu, BTreeMap<Op, Vec<String>>>,\n }\n \n@@ -148,6 +149,13 @@ pub struct SymbolStyleConfigEntry {\n     mods: Option<Modifier>,\n }\n \n+#[derive(Default, Debug, Deserialize)]\n+pub struct EditorConfig {\n+    pub default: Option<String>,\n+    pub show: Option<String>,\n+    pub commit: Option<String>,\n+}\n+\n impl From<&StyleConfigEntry> for Style {\n     fn from(val: &StyleConfigEntry) -> Self {\n         Style {\ndiff --git a/src/default_config.toml b/src/default_config.toml\nindex eaf97e7..b5a29fa 100644\n--- a/src/default_config.toml\n+++ b/src/default_config.toml\n@@ -10,6 +10,10 @@ confirm_quit.enabled = false\n collapsed_sections = []\n refresh_on_file_change.enabled = true\n \n+[editor]\n+# show = \"zed -a\"\n+# commit = \"zile\"\n+\n [style]\n # fg / bg can be either of:\n # - a hex value: \"#707070\"\n* Unmerged path src/ops/show.rs\n", pos: 1135, expected: "*EOF*" }

git diff --staged:

diff --git a/src/config.rs b/src/config.rs
index a22a438..095d9c7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -15,6 +15,7 @@ const DEFAULT_CONFIG: &str = include_str!("default_config.toml");
 pub(crate) struct Config {
     pub general: GeneralConfig,
     pub style: StyleConfig,
+    pub editor: EditorConfig,
     pub bindings: BTreeMap<Menu, BTreeMap<Op, Vec<String>>>,
 }
 
@@ -148,6 +149,13 @@ pub struct SymbolStyleConfigEntry {
     mods: Option<Modifier>,
 }
 
+#[derive(Default, Debug, Deserialize)]
+pub struct EditorConfig {
+    pub default: Option<String>,
+    pub show: Option<String>,
+    pub commit: Option<String>,
+}
+
 impl From<&StyleConfigEntry> for Style {
     fn from(val: &StyleConfigEntry) -> Self {
         Style {
diff --git a/src/default_config.toml b/src/default_config.toml
index eaf97e7..b5a29fa 100644
--- a/src/default_config.toml
+++ b/src/default_config.toml
@@ -10,6 +10,10 @@ confirm_quit.enabled = false
 collapsed_sections = []
 refresh_on_file_change.enabled = true
 
+[editor]
+# show = "zed -a"
+# commit = "zile"
+
 [style]
 # fg / bg can be either of:
 # - a hex value: "#707070"
* Unmerged path src/ops/show.rs

Example 2

panicked at src/git/mod.rs:155:64:
called `Result::unwrap()` on an `Err` value: ParseError { input: "diff --git a/src/config.rs b/src/config.rs\nindex a22a438..095d9c7 100644\n--- a/src/config.rs\n+++ b/src/config.rs\n@@ -15,6 +15,7 @@ const DEFAULT_CONFIG: &str = include_str!(\"default_config.toml\");\n pub(crate) struct Config {\n     pub general: GeneralConfig,\n     pub style: StyleConfig,\n+    pub editor: EditorConfig,\n     pub bindings: BTreeMap<Menu, BTreeMap<Op, Vec<String>>>,\n }\n \n@@ -148,6 +149,13 @@ pub struct SymbolStyleConfigEntry {\n     mods: Option<Modifier>,\n }\n \n+#[derive(Default, Debug, Deserialize)]\n+pub struct EditorConfig {\n+    pub default: Option<String>,\n+    pub show: Option<String>,\n+    pub commit: Option<String>,\n+}\n+\n impl From<&StyleConfigEntry> for Style {\n     fn from(val: &StyleConfigEntry) -> Self {\n         Style {\ndiff --git a/src/default_config.toml b/src/default_config.toml\nindex eaf97e7..b5a29fa 100644\n--- a/src/default_config.toml\n+++ b/src/default_config.toml\n@@ -10,6 +10,10 @@ confirm_quit.enabled = false\n collapsed_sections = []\n refresh_on_file_change.enabled = true\n \n+[editor]\n+# show = \"zed -a\"\n+# commit = \"zile\"\n+\n [style]\n # fg / bg can be either of:\n # - a hex value: \"#707070\"\n* Unmerged path src/ops/show.rs\n", pos: 1135, expected: "*EOF*" }
trace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2: std::backtrace::Backtrace::create
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/backtrace.rs:331:13
   3: gitu::main::{{closure}}
             at ./src/main.rs:27:34
   4: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/alloc/src/boxed.rs:2007:9
   5: std::panicking::rust_panic_with_hook
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:836:13
   6: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:701:13
   7: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/sys/backtrace.rs:168:18
   8: rust_begin_unwind
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
   9: core::panicking::panic_fmt
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
  10: core::result::unwrap_failed
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/result.rs:1704:5
  11: core::result::Result<T,E>::unwrap
             at /Users/moritz/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
  12: gitu::git::diff_staged
             at ./src/git/mod.rs:155:21
  13: gitu::screen::status::create::{{closure}}
             at ./src/screen/status.rs:94:26
  14: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /Users/moritz/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:2007:9
  15: gitu::screen::Screen::update
             at ./src/screen/mod.rs:208:22
  16: gitu::screen::Screen::new
             at ./src/screen/mod.rs:58:9
  17: gitu::screen::status::create
             at ./src/screen/status.rs:18:5
  18: gitu::state::State::create
             at ./src/state.rs:71:26
  19: gitu::run
             at ./src/lib.rs:92:21
  20: gitu::setup_term_and_run
             at ./src/main.rs:48:5
  21: gitu::main::{{closure}}::{{closure}}
             at ./src/main.rs:33:53
  22: gitu::term::raw_mode
             at ./src/term.rs:41:18
  23: gitu::main::{{closure}}
             at ./src/main.rs:33:35
  24: gitu::term::alternate_screen
             at ./src/term.rs:27:18
  25: gitu::main
             at ./src/main.rs:33:9

git diff --staged:

diff --git a/src/config.rs b/src/config.rs
index a22a438..095d9c7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -15,6 +15,7 @@ const DEFAULT_CONFIG: &str = include_str!("default_config.toml");
 pub(crate) struct Config {
     pub general: GeneralConfig,
     pub style: StyleConfig,
+    pub editor: EditorConfig,
     pub bindings: BTreeMap<Menu, BTreeMap<Op, Vec<String>>>,
 }
 
@@ -148,6 +149,13 @@ pub struct SymbolStyleConfigEntry {
     mods: Option<Modifier>,
 }
 
+#[derive(Default, Debug, Deserialize)]
+pub struct EditorConfig {
+    pub default: Option<String>,
+    pub show: Option<String>,
+    pub commit: Option<String>,
+}
+
 impl From<&StyleConfigEntry> for Style {
     fn from(val: &StyleConfigEntry) -> Self {
         Style {
diff --git a/src/default_config.toml b/src/default_config.toml
index eaf97e7..b5a29fa 100644
--- a/src/default_config.toml
+++ b/src/default_config.toml
@@ -10,6 +10,10 @@ confirm_quit.enabled = false
 collapsed_sections = []
 refresh_on_file_change.enabled = true
 
+[editor]
+# show = "zed -a"
+# commit = "zile"
+
 [style]
 # fg / bg can be either of:
 # - a hex value: "#707070"
* Unmerged path src/ops/show.rs

the-kenny avatar Apr 16 '25 08:04 the-kenny

Think this works now in master @the-kenny. Thanks for the heads up!

altsem avatar Apr 17 '25 18:04 altsem

I’ll check and close if fixed. Thanks!

the-kenny avatar Apr 18 '25 08:04 the-kenny

@the-kenny I assume it worked, closing this. Scream otherwise!

altsem avatar May 31 '25 15:05 altsem