jj/lib/tests
Kevin Liao 86b6a11e63 Fix jj init --git-repo fails and leaves broken .jj folder
This commit fixes #1305

Before this commit, running `jj init --git-repo=./` in a folder that
does not have a .git would cause jj to panick and leave an unfinished corrupted jj repo.

This commit fixes that by changing the call chain to return an error
instead of calling .unwrap() and panicking. This commit also adds logic to delete the unfinished jj
repository when the git backend initialization failed.

Before this commit, running the above command would result in the following
```
Running `jj/target/debug/jj init --git-repo=./`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: -3, klass: 2, message: "failed to resolve path '/Users/kevincliao/github/jj/test-repo/.jj/repo/store/../../../.git': No such file or directory" }', lib/src/git_backend.rs:83:75
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

After this commit, the result is the following and the jj repo is deleted:
```
Running `jj/target/debug/jj init --git-repo=./`
Error: Failed to access the repository: Error: Failed to open git repository: failed to resolve path '/Users/kevincliao/github/jj/test-repo/.jj/repo/store/../../../.git': No such file or directory; class=Os (2); code=NotFound (-3)
```
2023-06-20 11:02:06 -07:00
..
test_bad_locking.rs
test_commit_builder.rs git_backend: return timestamps for what was actually written 2023-05-12 15:20:44 -07:00
test_commit_concurrent.rs dag_walk: rename bfs() to dfs() because it's depth-first 2023-06-04 11:47:49 +09:00
test_conflicts.rs conflicts: move describe_conflict() etc. onto Conflict 2023-06-19 07:05:02 +02:00
test_default_revset_graph_iterator.rs index: pass only CompositeIndex to default_revset_engine::evaluate() 2023-05-29 08:15:40 +09:00
test_diff_summary.rs
test_git.rs Fix jj init --git-repo fails and leaves broken .jj folder 2023-06-20 11:02:06 -07:00
test_id_prefix.rs
test_index.rs index: turn CompositeIndex::walk_revs() into position-based API 2023-06-19 13:41:43 +09:00
test_init.rs
test_load_repo.rs
test_merge_trees.rs store: do conversion to/from backend::Conflict 2023-06-04 06:48:34 -07:00
test_mut_repo.rs
test_operations.rs
test_refs.rs
test_revset.rs revsets: stop jj parsing br as a git_ref refs/heads/br 2023-06-12 14:31:44 -07:00
test_rewrite.rs
test_view.rs
test_working_copy.rs store: do conversion to/from backend::Conflict 2023-06-04 06:48:34 -07:00
test_working_copy_concurrent.rs cleanup: leverage scoped thread in tests 2023-05-21 21:02:58 +09:00
test_working_copy_sparse.rs
test_workspace.rs