jj/lib/tests
bsdinis 35440ce1bd
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
git: spawn a separate git process for network operations
Reasoning:

`jj` fails to push/fetch over ssh depending on the system.
Issue #4979 lists over 20 related issues on this and proposes spawning
a `git` subprocess for tasks related to the network (in fact, just push/fetch
are enough).

This PR implements this.

Implementation Details:

This PR implements shelling out to `git` via `std::process::Command`.
There are 2 sharp edges with the patch:
 - it relies on having to parse out git errors to match the error codes
   (and parsing git2's errors in one particular instance to match the
   error behaviour). This seems mostly unavoidable

 - to ensure matching behaviour with git2, the tests are maintained across the
   two implementations. This is done using test_case, as with the rest
   of the codebase

Testing:

Run the rust tests:
```
$ cargo test
```

Build:
```
$ cargo build
```

Clone a private repo:
```
$ path/to/jj git clone --config='git.subprocess=true' <REPO_SSH_URL>
```

Create new commit and push
```
$ echo "TEST" > this_is_a_test_file.txt
$ path/to/jj describe -m 'test commit'
$ path/to/jj git push --config='git.subprocess=true' -b <branch>
```


Issues Closed

With a grain of salt, but most of these problems should be fixed (or at least checked if they are fixed). They are the ones listed in #4979 .

SSH:
- https://github.com/jj-vcs/jj/issues/63
- https://github.com/jj-vcs/jj/issues/440
- https://github.com/jj-vcs/jj/issues/1455
- https://github.com/jj-vcs/jj/issues/1507
- https://github.com/jj-vcs/jj/issues/2931
- https://github.com/jj-vcs/jj/issues/2958
- https://github.com/jj-vcs/jj/issues/3322
- https://github.com/jj-vcs/jj/issues/4101
- https://github.com/jj-vcs/jj/issues/4333
- https://github.com/jj-vcs/jj/issues/4386
- https://github.com/jj-vcs/jj/issues/4488
- https://github.com/jj-vcs/jj/issues/4591
- https://github.com/jj-vcs/jj/issues/4802
- https://github.com/jj-vcs/jj/issues/4870
- https://github.com/jj-vcs/jj/issues/4937
- https://github.com/jj-vcs/jj/issues/4978
- https://github.com/jj-vcs/jj/issues/5120
- https://github.com/jj-vcs/jj/issues/5166

Clone/fetch/push/pull:
- https://github.com/jj-vcs/jj/issues/360
- https://github.com/jj-vcs/jj/issues/1278
- https://github.com/jj-vcs/jj/issues/1957
- https://github.com/jj-vcs/jj/issues/2295
- https://github.com/jj-vcs/jj/issues/3851
- https://github.com/jj-vcs/jj/issues/4177
- https://github.com/jj-vcs/jj/issues/4682
- https://github.com/jj-vcs/jj/issues/4719
- https://github.com/jj-vcs/jj/issues/4889
- https://github.com/jj-vcs/jj/discussions/5147
- https://github.com/jj-vcs/jj/issues/5238

Notable Holdouts:
 - Interactive HTTP authentication (https://github.com/jj-vcs/jj/issues/401, https://github.com/jj-vcs/jj/issues/469)
 - libssh2-sys dependency on windows problem (can only be removed if/when we get rid of libgit2): https://github.com/jj-vcs/jj/issues/3984
2025-01-23 16:50:53 +00:00
..
runner.rs
test_annotate.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_bad_locking.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_commit_builder.rs repo: move rebase_descendants_with_options_return_map() to tests 2025-01-18 01:21:28 +00:00
test_commit_concurrent.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_conflicts.rs local_working_copy: store materialized conflict marker length 2024-12-21 11:36:30 -06:00
test_default_revset_graph_iterator.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_git.rs git: spawn a separate git process for network operations 2025-01-23 16:50:53 +00:00
test_git_backend.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_gpg.rs
test_id_prefix.rs repo: pass &Commit to record_abandoned_commit() to simplify error handling 2025-01-17 00:28:25 +00:00
test_index.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_init.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_load_repo.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_local_working_copy.rs local_working_copy: on snapshot, ignore submodule in ignored directories 2025-01-08 09:39:59 +09:00
test_local_working_copy_concurrent.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_local_working_copy_sparse.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_merge_trees.rs rewrite: back out 9d4a973 2025-01-07 09:08:46 -08:00
test_merged_tree.rs merged_tree: remove redundant .clone() from TreeDiffStreamImpl::new() 2024-11-30 10:20:43 +09:00
test_mut_repo.rs repo: move rebase_descendants_with_options_return_map() to tests 2025-01-18 01:21:28 +00:00
test_operations.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_refs.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_revset.rs graph: make reverse_graph() accept separate node id type 2025-01-22 00:44:42 +00:00
test_rewrite.rs rewrite: add option to delete abandoned bookmarks 2025-01-21 02:37:07 +00:00
test_rewrite_duplicate.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_rewrite_transform.rs repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
test_signing.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00
test_ssh_signing.rs
test_view.rs repo: pass &Commit to record_abandoned_commit() to simplify error handling 2025-01-17 00:28:25 +00:00
test_workspace.rs tests: add convenient method to initialize TestWorkspace with test settings 2025-01-06 22:37:33 +09:00