martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.39k stars 288 forks source link

Give better error message on invalid config #55

Closed martinvonz closed 2 years ago

martinvonz commented 2 years ago

I don't know if this is related, but setting the diff_editor under [ui] (in my case to "vimdiff") as instructed in the tutorial doesn't seem to work:

$ jj split -r 3dac3f00b3ad
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid TOML value, did you mean to use a quoted string? at line 4 column 15 in ../.jjconfig', src/main.rs:23:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ RUST_BACKTRACE=full jj split -r 3dac3f00b3ad
thread 'main' panicked at 'failed to run diff editor: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/diff_edit.rs:143:10
stack backtrace:
   0:     0x7fe018879fbc - std::backtrace_rs::backtrace::libunwind::trace::he080dbb637fa4641
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fe018879fbc - std::backtrace_rs::backtrace::trace_unsynchronized::h44a0cce058c40994
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe018879fbc - std::sys_common::backtrace::_print_fmt::hc4aa1034724314cb
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe018879fbc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2b790f8be1985180
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe0188a4dec - core::fmt::write::h84736921f2ac5f8d
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/core/src/fmt/mod.rs:1190:17
   5:     0x7fe018873a58 - std::io::Write::write_fmt::hfe23991a8d7fa4a7
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/io/mod.rs:1657:15
   6:     0x7fe01887c1e7 - std::sys_common::backtrace::_print::h67116a2d44eae1b1
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe01887c1e7 - std::sys_common::backtrace::print::h994f9a0072a4b217
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe01887c1e7 - std::panicking::default_hook::{{closure}}::h8f96a84dcab30cf8
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:295:22
   9:     0x7fe01887beaf - std::panicking::default_hook::hb573e2c3be78272d
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:314:9
  10:     0x7fe01887c94a - std::panicking::rust_panic_with_hook::h76b4576d8ac3b270
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:698:17
  11:     0x7fe01887c637 - std::panicking::begin_panic_handler::{{closure}}::h966318ad4399ecd3
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:588:13
  12:     0x7fe01887a464 - std::sys_common::backtrace::__rust_end_short_backtrace::h64a1117353180ced
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x7fe01887c339 - rust_begin_unwind
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:584:5
  14:     0x7fe0182cb213 - core::panicking::panic_fmt::h1e67b42cef1db7f9
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/core/src/panicking.rs:143:14
  15:     0x7fe0182cb303 - core::result::unwrap_failed::h1b1ad46cede6e9f5
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/core/src/result.rs:1749:5
  16:     0x7fe01834275c - jujutsu::diff_edit::edit_diff::h11f5f947fdd89247
  17:     0x7fe018306340 - jujutsu::commands::cmd_split::hbe0ab831be98217b
  18:     0x7fe0182cd006 - jujutsu::commands::dispatch::h215fb838a384e92c
  19:     0x7fe0182cddc1 - jj::main::h124478dc1575244a
  20:     0x7fe0182cded3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hec8c8455cb2b9a37
  21:     0x7fe0182cdec9 - std::rt::lang_start::{{closure}}::h11f6c49c99dcd502
  22:     0x7fe0188796a1 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h9d346f7455a6c7fd
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/core/src/ops/function.rs:259:13
  23:     0x7fe0188796a1 - std::panicking::try::do_call::h8ec1a9b8203a1bbc
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:492:40
  24:     0x7fe0188796a1 - std::panicking::try::h695a82b534df1aab
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:456:19
  25:     0x7fe0188796a1 - std::panic::catch_unwind::h6743ebe0ff045bfe
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panic.rs:137:14
  26:     0x7fe0188796a1 - std::rt::lang_start_internal::{{closure}}::h6e3fc46ec5fb4576
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/rt.rs:128:48
  27:     0x7fe0188796a1 - std::panicking::try::do_call::h5c849f12890c52cc
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:492:40
  28:     0x7fe0188796a1 - std::panicking::try::h2c36151dbc2fb3e1
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panicking.rs:456:19
  29:     0x7fe0188796a1 - std::panic::catch_unwind::h5cca8e7db56bc46a
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/panic.rs:137:14
  30:     0x7fe0188796a1 - std::rt::lang_start_internal::h0e034746b466501e
                               at /rustc/75d9a0ae210dcd078b3985e3550b59064e6603bc/library/std/src/rt.rs:128:20
  31:     0x7fe0182cdf02 - main
  32:     0x7fe017b06d0a - __libc_start_main
  33:     0x7fe0182cba4a - _start
  34:                0x0 - <unknown>
$ cat ~/.jjconfig
[user]
name = [REDACTED]
email = [REDACTED]
diff-editor = "vimdiff"

Originally posted by @EyeCon in https://github.com/martinvonz/jj/issues/18#issuecomment-1044055663

martinvonz commented 2 years ago

@EyeCon, I think the important bit is this:

invalid TOML value, did you mean to use a quoted string? at line 4 column 15 in ../.jjconfig'

I get that error if I leave out the quotes, making that line just diff-editor = vimdiff. Did you touch up the output in any other way than redacting the user and email?

By the way, the diff-editor value should be under [ui], not [user].

EyeCon commented 2 years ago

You are right, I actually tried both but pasted the wrong one apparently.

After moving it to [ui] (quoted), it works as expected.

martinvonz commented 2 years ago

Great :)

Out of curiosity, were you able to split a commit using vimdiff once you had fixed the config? I don't know vimdiff well enough to try it myself.

EyeCon commented 2 years ago

To be honest, vimdiff is not my first choice either but it was the only feasible one.

Yes, I just tested the commit splitting successfully. Thank you for the assistance. I'm looking forward to see this tool be usable for the production.