martinvonz / jj

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

Panic on `jj git fetch` #1107

Closed max-sixty closed 1 year ago

max-sixty commented 1 year ago

Description

Steps to Reproduce the Problem

I've been excited about jj for a while and tried it when it first came out. I just went to try using it again to see if it was more stable.

Unfortunately I got a panic on my first command:

> RUST_BACKTRACE=full jj git fetch
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotFound', lib/src/repo.rs:628:68
stack backtrace:
   0:        0x102866dd8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h71d20ef014883dc3
   1:        0x1028805e8 - core::fmt::write::hd114a9636e34e383
   2:        0x102851364 - std::io::Write::write_fmt::h05898edc92938c00
   3:        0x102857168 - std::panicking::default_hook::{{closure}}::hbd40827d346a3df4
   4:        0x102856df8 - std::panicking::default_hook::hf2e0d2c157a06c84
   5:        0x10285798c - std::panicking::rust_panic_with_hook::h33fd2dae40c879df
   6:        0x1028674d0 - std::panicking::begin_panic_handler::{{closure}}::h81ef06081ce645db
   7:        0x102866f14 - std::sys_common::backtrace::__rust_end_short_backtrace::hc514eeb5ddb8eaf3
   8:        0x1028575ac - _rust_begin_unwind
   9:        0x1028c15e8 - core::panicking::panic_fmt::h520fb0ef56e6cee7
  10:        0x1028c145c - core::result::unwrap_failed::he039a87cd569f3fd
  11:        0x1025a7a7c - jujutsu_lib::repo::MutableRepo::leave_commit::h896f43d7e6b77c02
  12:        0x1025a7588 - jujutsu_lib::repo::MutableRepo::check_out::h2c3f801c1bdaede0
  13:        0x102480078 - jujutsu::cli_util::WorkspaceCommandHelper::snapshot::h24ef76971f687201
  14:        0x10247d3b4 - jujutsu::cli_util::CommandHelper::workspace_helper::hc111ba7329e596f1
  15:        0x1023e977c - jujutsu::commands::cmd_git::h2490f4b906d3e4c9
  16:        0x1023eb534 - jujutsu::commands::run_command::h055b2d67c6f673e5
  17:        0x1023a296c - core::result::Result<T,E>::and_then::hb5f96a3938355d21
  18:        0x1023a2cb0 - jj::main::hbfe0aebb19b8f287
  19:        0x1023a4ae0 - std::sys_common::backtrace::__rust_begin_short_backtrace::he3979f96be648ca8
  20:        0x1023ad6b4 - std::rt::lang_start::{{closure}}::had66d8f2d4d9c0fd
  21:        0x102856080 - std::rt::lang_start_internal::h3f58ab0124dae34f
  22:        0x1023a2db8 - _main

Unfortunately I can't share the repo or its state, but happy to try again if the panic is turned into an error in a future version.

Specifications

ilyagr commented 1 year ago

I'm pretty sure it's this unwrap:

https://github.com/martinvonz/jj/blob/c82a62cf99181579d94ccf36611be9d40c20c330/lib/src/repo.rs#L777

I wonder if this is a symptom of a shallowly cloned repo, or of only a part of the tree being checked out. It would be nice to have an error that explains which feature relevant to a particular repo jj doesn't support :).

martinvonz commented 1 year ago

I agree, it does seem to be that line. @max-sixty, how did you create the repo? By a regular git clone and then jj init --git-repo=. in the clone? Did you use shallow or partial clone?

And yes, we should obviously propagate that error instead of panicking.

max-sixty commented 1 year ago

I think I had a git repo from a normal git clone, and then ran that command...

martinvonz commented 1 year ago

I think I had a git repo from a normal git clone, and then ran that command...

Hmm, then you probably have a .jj/ directory next to your .git/ directory, right? If that directory is from last time you tried jj, it might be an incompatibility. We try to automatically upgrade the repo if necessary, but only when you upgrade jj one minor version (e.g. 0.5.x to 0.6.x). Try removing the .jj/ directory, and then run jj init --git-repo=. to set it up again.

max-sixty commented 1 year ago

If that's directory is from last time you tried jj, it might be an incompatibility. We try to automatically upgrade the repo if necessary, but only when you upgrade jj one minor version (e.g. 0.5.x to 0.6.x).

That's correct, it works!

I'll close. BTW it would be fine it the error said "your repo is out of date, please delete and rebuild", way better than a panic; hope that's reasonable to say.

Looking forward to exploring jj more!

martinvonz commented 1 year ago

I'll close. BTW it would be fine it the error said "your repo is out of date, please delete and rebuild", way better than a panic; hope that's reasonable to say.

Agreed. We have some work on making jj error out both on too old and too new repos. I've also started working on making the error you ran into at least not be a panic.