Commit graph

3890 commits

Author SHA1 Message Date
Martin von Zweigbergk
d4e755b4e4 merged_tree: rename some symbols away from "conflict"
There were still many instances of `conflict` left from before we
renamed `Conflict<T>` to `Merge<T>`. I decided to rename many of them
based on the type parameter instead of the container. I think that
made it more readable in many cases.
2023-08-11 21:11:25 +00:00
Martin von Zweigbergk
a995c66635 merge: move some methods back to conflicts as free functions
I think I moved way too many functions onto `Merge<Option<TreeValue>>`
in 82883e648d. This effectively reverts almost all of that
commit. The `Merge<T>` type is simple container and it seems like it
should be at fairly low level in the dependency graph. By moving
functions off of it, we can get rid of the back-depdencies from the
`merge` module to the `conflict` module that I introduced when I moved
`Merge` to the `merge` module. I'm thinking the `conflict` module can
focus on materialized conflicts.
2023-08-11 21:11:25 +00:00
Ben Saunders
e563d60e64 Update docs and errors to use XDG config path 2023-08-11 13:21:44 -07:00
Yuya Nishihara
925d54614d revset: remove round-trip conversion from heads() evaluation
This wouldn't matter much in practice, but I think it's better to stick to
low-level index primitives during revset evaluation.
2023-08-12 02:16:29 +09:00
Matt Stavola
4760b565c5 configs: add the ability to disable paging via ui.paginate 2023-08-11 12:45:53 -04:00
dependabot[bot]
083e971dfb cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).

- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.7...v0.38.8)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-11 15:36:19 +00:00
Austin Seipp
1abd36725a envrc: use nix-direnv instead of default direnv nix support
Summary: It releases more frequently and tends to fix more bugs frequently than
direnv; it also seems to (in my experience) behave better with caching in flake
and non-flake scenarios.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I39f08cd691eeac8e243c2e059edfaa9c
2023-08-11 04:06:48 -05:00
Austin Seipp
8b2801887e nix: 'nix flake update'
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I164d8a6679516dbf1e5ef726d341ec41
2023-08-11 04:06:48 -05:00
Martin von Zweigbergk
d1dbe6de98 git: propagate errors for missing commits when importing refs 2023-08-11 05:06:36 +00:00
Yuya Nishihara
0cbee40aec cli: attach stderr stream of external diff command to pager
It's messy if pager and child output are interleaved as the pager controls
the tty.

Windows code is untested. I think the underlying I/O behavior is similar, but
I don't have expertise.
2023-08-11 13:47:13 +09:00
Yuya Nishihara
4c9c923258 cli: show warning if external diff generator exited with non-zero status 2023-08-11 13:47:13 +09:00
Yuya Nishihara
9dbadda150 cli: pass ui in to merge_tools::generate_diff()
Two things will be added:
a. show warning if child exited with non-zero status
b. attach pager stdin to stderr of child process

I think (a) could be propagated from generate_diff() as an error variant, but
for (b), it makes sense to pass ui down to the function.
2023-08-11 13:47:13 +09:00
Ilya Grigoriev
6fa8a25839 cli templates: include branches in short commit description
They are shown next to the change and commit id, since they are other names the
commit can be referred by. 

The description is separated from the branches by a ` | ` when there are
branches, so that one can tell the branches from the description without color.

The result looks like this: ![image](https://github.com/martinvonz/jj/assets/4123047/a38aff7b-2b47-49e6-8461-c42e8eb535a4)
2023-08-10 20:58:40 -07:00
Ilya Grigoriev
355b93fdd6 cli branch list: use separate short commit template
We will shortly add branches to the short commit template, but that is undesireable
for `jj branch list`.
2023-08-10 20:58:40 -07:00
Yuya Nishihara
17b45d642f cli: add "--limit N" option to log-like commands
Copied from Mercurial. This isn't a revset predicate since our revset is
conceptually unordered.
2023-08-11 10:40:40 +09:00
Martin von Zweigbergk
abc7312dbc working_copy: avoid an unused variable on Windows 2023-08-11 01:14:52 +00:00
Yuya Nishihara
fb41ef4fa0 cli: handle invalid ui.editor configuration 2023-08-11 08:09:41 +09:00
Martin von Zweigbergk
a367f13c72 configs: use Notepad as default editor on Windows 2023-08-10 17:09:07 +00:00
Martin von Zweigbergk
32b07d6b79 cli: move default editor (pico) definition to config file 2023-08-10 17:09:07 +00:00
Yuya Nishihara
b2101d15c8 cli: detect .git symlink as a colocated workspace
Maybe we could load GitBackend without resolving .git symlink, but that would
introduce more subtle bugs. Instead, we calculate the expected Git workdir path
from the canonical ".git" path.

Fixes #2011
2023-08-10 14:53:54 +09:00
Yuya Nishihara
900300cf5f cli: do not panic if clone destination directory can't be created
wc_path.canonicalize() can also fail, but that's probably because of racy
clone and the directory creation would have effectively failed.
2023-08-10 07:18:06 +09:00
Yuya Nishihara
97b6eb2684 cli: clean up .git directory if "jj git clone --colocate" failed 2023-08-10 07:18:06 +09:00
Yuya Nishihara
6625e91a4b cli: send "Failed to clean up" message to stderr 2023-08-10 07:18:06 +09:00
Yuya Nishihara
d039008db8 cli: add tests for failed "jj git clone"
Perhaps, the message "(os error 39)" isn't portable, but I don't care since
it will be fixed by later patch.
2023-08-10 07:18:06 +09:00
Martin von Zweigbergk
0570963fe3 merge: add a Merge::into_resolved() to avoid cloning
I don't know if this has any measurable impact. It just seems like we
should be able to take a resolved value out of a `Merge` without
clonning.
2023-08-09 21:58:15 +00:00
Martin von Zweigbergk
f7160cf936 merge: add absent() and normal() to Merge<Option<T>>
These mimic the `RefTarget` functions. They're very useful in
`MergedTree`.

I might copy over other helpers from `RefTarget` later.
2023-08-09 21:58:15 +00:00
Yuya Nishihara
530547eb9c tests: test that git::import_refs() can update conflicted remote branch
Per discussion in #2009. This behavior isn't affected by e7e49527ef "git:
ensure that remote branches never diverge", but it's subtle enough to write
a test.
2023-08-10 06:27:16 +09:00
Yuya Nishihara
552c71ed36 tests: move commit_transactions() helper to testutils 2023-08-10 06:27:16 +09:00
Martin von Zweigbergk
dd3b4bfb33 cargo: run cargo update 2023-08-09 18:38:24 +00:00
dependabot[bot]
25b8505196 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [tokio](https://github.com/tokio-rs/tokio).

- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.29.1...tokio-1.30.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-09 08:50:34 -07:00
Yuya Nishihara
e7e49527ef git: ensure that remote branches never diverge
I was considering how refs would be imported if we had a per-remote view of
named branches (and tags): Each remote has a view, and jj remembers the last
known view state to compute diffs. That's the same for the pseudo "git" remote.
Under the current storage, these view states are represented as follows:

  git_refs["refs/heads/{name}"]             # pseudo "git" remote branches
  git_refs["refs/tags/{name}"]              # pseudo "git" remote tags
  git_refs["refs/remotes/{remote}/{name}"]  # real remote branches

and the diffs are merged in to branches[name].local_target and tags[name].

We also have branches[name].remote_targets[remote], but I think it's redundant
because a tracking branch should also be the last known state, not something
that can diverge from the actual state. To make that clear, this commit
replaces the use of the "merge" API.
2023-08-09 15:22:45 +09:00
Martin von Zweigbergk
56472297f0 git: add support for SSH authentication with ed25519 or ed25519-sk
This makes it possible to use ed25519 and ed25519-sk keys by trying
them one at a time. However, it still fails if one of them is
password-protected; we don't try the next key in that case.
2023-08-09 03:44:03 +00:00
Martin von Zweigbergk
1d2324ae5c git: refactor SSH key callbacks to allow multiple keys
This is to prepare for adding support for checking other keys than
just id_rsa.
2023-08-09 03:44:03 +00:00
Benjamin Saunders
7cf518a530 cli: don't call a safe function 'unsafe' 2023-08-08 20:42:19 -07:00
Martin von Zweigbergk
1a4cf13033 faq: minor fixes and cleanups 2023-08-09 03:15:26 +00:00
Philip Metzger
8188dc42df Docs: Add a FAQ
This answers some questions, which were repeatedly asked in Discord.
2023-08-09 01:19:55 +02:00
Benjamin Saunders
75636d626f local_backend: don't reference uninitialized memory 2023-08-08 13:08:26 -07:00
dependabot[bot]
fa758893cf cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).

- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.3.19...v4.3.21)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-08 15:59:57 +00:00
Martin von Zweigbergk
c752b43db1 git: only try to use ssh-agent once per connection
As reported in #1970, SSH authentication would sometimes run into a
loop where it repeatedly tries to use ssh-agent for authentication
without making progess. The problem can be reproduced by simply
removing `$SSH_AUTH_KEY` from your environment (and not having a Git
credentials helper configured, I think).

This seems to be a bug introduced by b104f8e154c21. That commit meant
to make it so we attempt to use ssh-agent and fall back to using
(password-less) keys after that. The problem is that
`git2::Cred::ssh_key_from_agent()` just returns an object that will be
used later for looking up the credentials from ssh-agent, so the call
will not fail because ssh-agent is not reachable.

This commit attempts to fix the problem by having the credentials
callback attempt to use ssh-agent only once.
2023-08-08 07:41:13 +00:00
Ilya Grigoriev
a9e5e97025 test_git_push: Test git.push-branch-prefix config 2023-08-07 19:10:10 -07:00
Ilya Grigoriev
add867cfae test_git_push: use -c instead of --change occasionally 2023-08-07 19:10:10 -07:00
Ilya Grigoriev
74d9970908 config: Rename push.branch-prefix option to git.push-branch-prefix
This is for consistency with other `git.` options. See also
https://github.com/martinvonz/jj/pull/1962#discussion_r1282605185
2023-08-07 19:10:10 -07:00
Ilya Grigoriev
9e08b52d55 merge_tools: make dirs readonly for external difftool
As far as I understand, the difftool is supposed to be readonly,
so let's encourage people to no edit the files being diffed.
2023-08-07 17:17:35 -07:00
Martin von Zweigbergk
cc335a9970 cargo: move examples/ into cli/ so they are part of the build again 2023-08-07 21:49:45 +00:00
dependabot[bot]
9bc8ff9f1d cargo: bump the cargo-dependencies group with 4 updates
Bumps the cargo-dependencies group with 4 updates: [regex](https://github.com/rust-lang/regex), [rustix](https://github.com/bytecodealliance/rustix), [serde](https://github.com/serde-rs/serde) and [tempfile](https://github.com/Stebalien/tempfile).


Updates `regex` from 1.9.1 to 1.9.3
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.1...1.9.3)

Updates `rustix` from 0.38.6 to 0.38.7
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.6...v0.38.7)

Updates `serde` from 1.0.181 to 1.0.183
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.181...v1.0.183)

Updates `tempfile` from 3.7.0 to 3.7.1
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.7.0...v3.7.1)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: rustix
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 15:59:28 +00:00
Yuya Nishihara
2619200657 refs: rename RefTarget::as_conflict() to as_merge()
Follows up ecc030848d. It's also nice that we have more distinction between
has_conflict() ans as_merge().
2023-08-07 08:05:57 +09:00
Martin von Zweigbergk
b9b285c985 conflicts: move Merge tests to merge module
I missed the tests when I moved the type.
2023-08-06 23:05:21 +00:00
Martin von Zweigbergk
af2dba1c8f merge: move tests module to end of file
I used IntelliJ to move the `Merge` type from the `conflict` module
and didn't notice until now that it put the moved items after the
tests.
2023-08-06 23:05:21 +00:00
Martin von Zweigbergk
14ddd17673 working_copy: add debug assertion that tree and file states match
Perhaps the most important invariant in `.jj/working_copy/tree_state`
is that its set of files in it matches the files in its tree. In
particular, if a file that exists in the tree doesn't exist in the
file state and doesn't exist on disk either, we won't notice that it's
gone, and we will therefore not delete it from the tree on future
rounds of snapshotting either.
2023-08-06 22:17:18 +00:00
Martin von Zweigbergk
6cce5e758b working_copy: reduce scope of some variables
With the recent refactorings, we don't need the `tree_builder` and
`deleted_files` until a bit later.
2023-08-06 22:17:18 +00:00