jj/cli/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
..
common git: spawn a separate git process for network operations 2025-01-23 16:50:53 +00:00
cli-reference@.md.snap cli: describe: Add a --edit flag 2025-01-23 16:11:32 +00:00
runner.rs
test_abandon_command.rs cli: abandon: delete bookmarks pointing to abandoned commits 2025-01-21 02:37:07 +00:00
test_absorb_command.rs absorb: print status if source commit still contains diffs 2025-01-16 01:09:33 +00:00
test_acls.rs cli: port "file list" to template 2025-01-23 02:21:15 +00:00
test_advance_bookmarks.rs
test_alias.rs
test_backout_command.rs
test_bookmark_command.rs
test_builtin_aliases.rs
test_commit_command.rs
test_commit_template.rs cli: port "file list" to template 2025-01-23 02:21:15 +00:00
test_completion.rs cli: autocomplete: complete config values in addition to keys 2025-01-13 14:43:40 +00:00
test_concurrent_operations.rs
test_config_command.rs
test_copy_detection.rs
test_debug_command.rs
test_describe_command.rs cli: describe: Add a --edit flag 2025-01-23 16:11:32 +00:00
test_diff_command.rs
test_diffedit_command.rs
test_duplicate_command.rs
test_edit_command.rs
test_evolog_command.rs
test_file_annotate_command.rs
test_file_chmod_command.rs
test_file_show_command.rs
test_file_track_untrack_commands.rs
test_fix_command.rs actions: fix codespell CI failure 2025-01-22 00:20:33 +00:00
test_generate_md_cli_help.rs
test_git_clone.rs git: spawn a separate git process for network operations 2025-01-23 16:50:53 +00:00
test_git_colocated.rs
test_git_fetch.rs git: spawn a separate git process for network operations 2025-01-23 16:50:53 +00:00
test_git_import_export.rs
test_git_init.rs
test_git_private_commits.rs
test_git_push.rs git: spawn a separate git process for network operations 2025-01-23 16:50:53 +00:00
test_git_remotes.rs
test_git_submodule.rs
test_gitignores.rs
test_global_opts.rs
test_help_command.rs
test_immutable_commits.rs restore: add --into flag, make --to an alias to it 2025-01-19 20:17:44 +00:00
test_init_command.rs
test_interdiff_command.rs
test_log_command.rs revset: duplicate Rule::identifier to strict_identifier, replace some usages 2025-01-15 07:24:10 +00:00
test_new_command.rs
test_next_prev_commands.rs
test_operations.rs cli: op log: add --reversed option 2025-01-12 01:51:25 +00:00
test_parallelize_command.rs
test_rebase_command.rs
test_repo_change_report.rs
test_resolve_command.rs
test_restore_command.rs restore: add --into flag, make --to an alias to it 2025-01-19 20:17:44 +00:00
test_revset_output.rs revset: split author()/committer() into _name()/email() predicates 2025-01-21 01:10:00 +00:00
test_root.rs
test_shell_completion.rs
test_show_command.rs
test_simplify_parents_command.rs
test_sparse_command.rs
test_split_command.rs
test_squash_command.rs
test_status_command.rs
test_tag_command.rs
test_templater.rs
test_undo.rs
test_unsquash_command.rs
test_util_command.rs
test_working_copy.rs
test_workspaces.rs