git-branchless icon indicating copy to clipboard operation
git-branchless copied to clipboard

Panic on `git branchless init` in a non-git directory

Open dragon-dxw opened this issue 2 years ago • 0 comments

Description of the bug

First time using git branchless, I accidently ran the command in the parent folder of my git repos, rather than in a git repo.

I did not expect an uncaught panic.

Expected behavior

A polite error message informing me of the mistake I'd made.

Actual behavior

A panic.

The application panicked (crashed).
Message:  A fatal error occurred: 
   0: could not open repository: could not find repository from '/Users/dragon/dxw/archives'; class=Repository (6); code=NotFound (-3)
   1: could not find repository from '/Users/dragon/dxw/archives'; class=Repository (6); code=NotFound (-3)

Location:
   git-branchless-init/src/lib.rs:606

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   0: git_branchless_init::command_init with effects=<Output fancy=true> git_run_info=<GitRunInfo path_to_git="git" working_directory="/Users/dragon/dxw/archives" env=not shown> main_branch_name=None
      at git-branchless-init/src/lib.rs:599
   1: git_branchless_init::command_main with ctx=CommandContext { effects: <Output fancy=true>, git_run_info: <GitRunInfo path_to_git="git" working_directory="/Users/dragon/dxw/archives" env=not shown> } args=InitArgs { uninstall: false, main_branch_name: None }
      at git-branchless-init/src/lib.rs:668

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Location: git-branchless/src/commands/mod.rs:235

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

git-branchless-opts 0.8.0

Version of git

git version 2.42.0

dragon-dxw avatar Sep 21 '23 12:09 dragon-dxw