2112 Commits

Author SHA1 Message Date
Yuya Nishihara
994c6a457a cli: remove handling of null terminated string from git sideband writer
I think this is copy-paste error from C implementation.
2025-02-01 00:41:51 +00:00
Yuya Nishihara
fc82e99ae9 cli: move cursor to first column after printing git progress bar
This helps sideband writer overwrite the progress bar. Suppose progress
information is less important than sideband messages, it should be okay to
always overwrite the progress bar. The sideband writer will erase the trailing
characters and move the cursor back to the first column, and/or put "\n"
accordingly.
2025-02-01 00:41:51 +00:00
Antoine Martin
c2acc49be5 docs: document the ui.movement.edit config option
This option was introduced in #4283, but was not documented apart from
`prev` and `next`'s help text on the --edit/--no-edit flags.
2025-01-31 23:10:34 +00:00
Martin von Zweigbergk
0f1a6fc4ae rebase: clarify -d/-A/-B arguments with examples 2025-01-31 16:08:15 +00:00
Martin von Zweigbergk
0d00de72c6 cli: git: escape bookmark and remote names in trunk() config
Closes #5359.
2025-01-31 15:54:47 +00:00
Yuya Nishihara
b637e98127 git: enable sideband message callback globally, disable on fetch without tty
With this and "git --progress" PR #5519, remote git progress will be displayed.

The sideband callback is disabled in git2 code path if progress is not enabled.
If this were enabled, most "git fetch" tests would fail with git2 due to remote
progress messages. Since there's no git2 API to turn the remote progress off,
and the git2 code path is supposed to be phased out, I just inserted ad-hoc
workaround.
2025-01-31 01:47:34 +00:00
Yuya Nishihara
4dd9c5f0a7 git: simplify cast of progress callback 2025-01-31 01:47:34 +00:00
Yuya Nishihara
cdbfd6bc51 git: reimplement get_all_remotes() by using gix API 2025-01-31 00:52:23 +00:00
Yuya Nishihara
7a1cd6a0f6 git: factor out common get_git_backend/repo() helper, simplify error handling 2025-01-31 00:52:23 +00:00
Jakob Hellermann
3293a1aa97 cli: completion: derive clap::ValueEnum for ColorChoice
This enables autocompletion for `jj --color <TAB>`
2025-01-29 22:51:24 +00:00
Matt Kulukundis
5b5a9e71c3 docs: improve cli docs for consistency and links 2025-01-29 18:01:16 +00:00
Baltasar Dinis
120b9cc766 git: forward remote messages to output 2025-01-28 21:56:04 +00:00
Baltasar Dinis
e8620c31ae git: describe codepaths that require git2 2025-01-28 18:29:01 +00:00
Baltasar Dinis
eb1d70317a cli: relocate git fetch code to cli/src/commands/git/fetch.rs
This code was living in cli/src/git_utils.rs but no one else was using
it
2025-01-28 18:29:01 +00:00
Baltasar Dinis
1be574c219 git: update jj git clone|fetch to use new GitFetch api directly.
* Make the new `GitFetch` api public.
* Move `git::fetch` to `lib/tests/test_git.rs` as `git_fetch`, to minimize
  churn in the tests. Update test call sites to use `git_fetch`
* Delete the `git::fetch` from `lib/src/git.rs`.
* Update `jj git clone` and `git_fetch` in `cli/src/git_utils.rs` to use
  the new api directly. Removing one redundant layer of indirection.
* This fixes #4920 as it first fetches from all remotes before `import_refs()`
  is called, so there is no race condition if the same commit is treated
  differently in different remotes specified in the same command.

Original commit by @essiene
2025-01-28 18:29:01 +00:00
Yuya Nishihara
90e79348e3 diff: remove ad-hoc rename handling in show_diff_stat()
Renamed entries are omitted by iterator/stream since 352a4a0eea8e "copies:
filter rename source entries by CopiesTreeDiffStream."
2025-01-28 01:44:57 +00:00
Ilya Grigoriev
f4346f2e51 cli reference & jj log --help: render URLs in CLI refrerence
Fixes #5490 (we can catch other instances of this manually)

Note that it links to the `latest` even if you are looking at the
`prerelease` docs. This is not ideal, but seems annoying to fix.
2025-01-28 00:50:54 +00:00
Bryce Berger
1bcd55d077 cli: remove double ": : " on git password prompt
`ui.prompt_password()` already adds ": " to the end of the prompt.
Remove the extra at the (only) callsite, to keep similarity to the above
`terminal_get_pw()`.
2025-01-27 22:59:40 +00:00
Yuya Nishihara
93d98f11ba cli: git clone: reload workspace after configuring new remote
I originally thought we could just reinitialize RepoLoader, but it wasn't
enough. Since LocalWorkingCopy holds Arc<Store>, we need to reinstantiate both
working copy and repo loader.
2025-01-27 11:03:39 +00:00
Yuya Nishihara
94754b7f49 cli: add helper method to load workspace at arbitrary path
map_workspace_load_error() is slightly adjusted because we now have three
"user" wc path options: 1. cwd (default), 2. -R path, 3. internal API call.
2025-01-27 11:03:39 +00:00
Yuya Nishihara
dcca1811fe cli: apply log --limit before --reversed
As I said, I don't have strong feeling about the current behavior, and appears
that "log | head | reverse" is preferred over "log | reverse | head".
"jj evolog" already behaves differently, so I just updated the doc.

Note that the new behavior might be slightly different from git, but nobody
would care. (iirc, in git, topological sorting comes later.)

Closes #5403
2025-01-27 01:35:36 +00:00
Yuya Nishihara
9985dce0ab revset: inline reversed() iterator to caller
The implementation isn't specific to revset, and is short.
2025-01-27 01:35:36 +00:00
Ilya Grigoriev
332b8d774a config-schema.json: fixup to default-command
Before this commit, both VS Code's "Even better TOML" and `taplo`
reported an error saying `["status","--no-pager"] is not of type
"string"` for

```toml 
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
ui.default-command = ["status", "--no-pager"]
``` 

I believe the schema was either invalid or just ignored `oneOf` because
it was trivially satisfied whenever the `type` restriction was
satisfied.
2025-01-26 06:03:40 +00:00
Yuya Nishihara
fe54c6276e templater: add diff.files() method
This can be used in order to count the number of added files by
diff.files().filter(..).len(), for example. If we add more advanced fileset
predicates, it can also be expressed as diff("added()").files().len(). The
latter would be cheaper to compute.

For #4154, I'll probably add DiffStats template type. It might be doable by
extending diff.files() method, but I don't think it's good idea to write stats
calculation logic in template language.

Closes #5272
2025-01-26 01:54:33 +00:00
Yuya Nishihara
b22347e80b templater: add TreeDiffEntry types
Tests will be added later.
2025-01-26 01:54:33 +00:00
Yuya Nishihara
e21f8e62cb diff: extract function that maps diff entry to status label and char
I'm going to add diff_entry.status() template method.
2025-01-26 01:54:33 +00:00
Bryce Berger
cbb743cfb5 config: add --when.command to scope resolution
Closes #5217

Motivating use case:

    [[--scope]]
    --when.command = ["log"]
    [--scope.ui]
    pager = "less"

This adds a new (optional) field to `--when` config conditions, to
inspect the current command.

`--when.commands` is a list of space-separated values that matches a
space-separated command. To be specific:

    --when.command = ["file"]        # matches `jj file show`, `jj file list`, etc
    --when.command = ["file show"]   # matches `jj file show`, but *NOT* `jj file list`
    --when.command = ["file", "log"] # matches `jj file` *OR* `jj log` (or subcommand of either)

When both `--when.commands` and `--when.repositories` are set, the
intersection is used.
2025-01-24 05:30:07 +00:00
Yuya Nishihara
362be5914f templater: add list.filter(predicate) method
If we add generic diff template, we'll probably want to filter diff entries by
status, etc.

Closes #5291
2025-01-24 03:42:39 +00:00
Yuya Nishihara
af05534108 templater: extract helper that builds lambda expression body
I also made the helper function accept multiple parameters/arguments as doing
that was easy.
2025-01-24 03:42:39 +00:00
Yuya Nishihara
9683d81f03 templater: load diff parameters from config file
It didn't before just because UserSettings wasn't available to the templater.
2025-01-24 03:42:26 +00:00
Yuya Nishihara
3ed77c9bb3 cli: split diff options constructors to not require command args 2025-01-24 03:42:26 +00:00
Yuya Nishihara
fb25e8a4ad cli: add hint to config error occurred within templater 2025-01-24 03:42:26 +00:00
bsdinis
35440ce1bd 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
Jonathan Frere
55d1c17245 cli: describe: Mark conflicting message/stdin args 2025-01-23 16:11:32 +00:00
Jonathan Frere
e63d1d5114 cli: describe: Add a --edit flag
The --edit flag forces the editor to be shown, even if it would have
been hidden due to the --no-edit flag or another flag that implies it
(such as --message or --stdin).
2025-01-23 16:11:32 +00:00
Yuya Nishihara
8eebac54fc cli: port "file list" to template 2025-01-23 02:21:15 +00:00
Yuya Nishihara
7db343ec32 templater: add TreeEntry type
I'm going to add "file list" template, and I think it's better to provide a file
path as "path", not "self". This patch also adds some tree value properties
which seemed useful.

Tests will be added later.
2025-01-23 02:21:15 +00:00
Yuya Nishihara
5062ae83d3 templater: add RepoPath types
This will be used in "file list" template. Option<RepoPath> type isn't
needed for that, but I think it'll appear somewhere in custom diff template.
The path.parent() method is added mainly for testing Option<RepoPath>.

Tests will be added later.
2025-01-23 02:21:15 +00:00
Yuya Nishihara
ce3100a8cd cli: reformat config/templates.toml
.editorconfig is set to trim trailing whitespace. I also adjusted indent style
and trailing commas.
2025-01-23 02:21:15 +00:00
Yuya Nishihara
2129c8996f cli: migrate "git remote list" to gix
This one is easy, but porting other "jj git remote" sub commands would require
non-trivial work.

The empty [remote "<name>"] case is covered by existing tests.
2025-01-22 12:39:46 +00:00
Yuya Nishihara
9d77ad5594 config: add separate type for migration error, attach source path
Migration can fail because of unexpected value type, etc.
2025-01-22 01:01:04 +00:00
Ilya Grigoriev
231c968f51 dynamic completion: complete jj git push {-r,-c}
I had to guess whether to complete all revisions or just mutable ones. I'm
guessing that `-r` is sometimes used with immutable revisions (as part of a
revset, or for creating special-purpose branches), while `-c` is almost always
used to push a mutable revision. We can change it later if my guess is wrong.
2025-01-22 00:45:46 +00:00
Ilya Grigoriev
cf69a36a62 dynamic completion: add revision completion to hidden -r arguments
Before this commmit, `jj desc <tab>` resulted in revision completions, but the equivalent `jj desc -r <tab>` didn't.
2025-01-22 00:45:46 +00:00
Yuya Nishihara
a6f20cf42f graph: make reverse_graph() accept separate node id type
Although extra clone/IO wouldn't matter in practice, we can simplify callers
by constructing the edges list to be passed to the graph renderer.
2025-01-22 00:44:42 +00:00
Martin von Zweigbergk
be32d4e3ef cli: rebase: say that -r allows set, clarify -s X vs -r X:: 2025-01-21 06:43:15 +00:00
Yuya Nishihara
4a50a35046 cli: abandon: delete bookmarks pointing to abandoned commits
Based on the discussion in #3505, I think the sliding behavior isn't favored at
least for "jj abandon". This patch changes the default to delete bookmarks.

"jj rebase --skip-emptied" can also be updated if needed. It might be good for
consistency. However, I'm skeptical about changing the default of the internal
API. It's not easy to add generic reporting mechanism for deleted/abandoned
bookmarks. If we added one in report_repo_changes(), redundant message would be
printed on "jj git fetch". So I think callers should enable the deletion
explicitly.

Closes #3505
2025-01-21 02:37:07 +00:00
Yuya Nishihara
686ab24a5c cli: abandon: use transform_descendants() to do reparent/rebase conditionally
This will help implement "jj abandon --retain-bookmarks".
2025-01-21 02:37:07 +00:00
Yuya Nishihara
c50a70906b rewrite: add option to delete abandoned bookmarks
I'll make "jj abandon" delete bookmarks by default. This could be handled by
cmd_abandon(), but we'll need a repo API if we also want to change the behavior
of "jj rebase --skip-emptied".
2025-01-21 02:37:07 +00:00
Yuya Nishihara
9663509643 cli: handle remote configuration error on "git clone" 2025-01-21 01:19:15 +00:00
Yuya Nishihara
2415c96cd8 cli: split do_git_clone() function to reduce number of arguments 2025-01-21 01:19:15 +00:00