ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

500 commits

Author SHA1 Message Date
Yuya Nishihara
55b4f69fb6 repo: propagate store error from add_heads() 2023-12-24 00:22:30 +09:00
Yuya Nishihara
1836a105bb cli: warn if -R/--repository could be involved in command alias expansion
#2414
2023-12-24 00:20:38 +09:00
Yuya Nishihara
30b5e88b04 cli: use cwd-relative workspace config to resolve default command and aliases
This is basically the same as Mercurial's workaround. I don't know about Git,
but arguments order is very restricted in git, so -C path can be parsed prior
to alias expansion. In hg and jj, doing that would be messy and unreliable.

Closes #2414
2023-12-24 00:20:38 +09:00
Yuya Nishihara
941e53802f cli: error out early if -R path is invalid
It should be better to handle invalid -R path globally. The error message is
a bit worse, but I think it's still okay.

This helps to load temporary config from the cwd-relative path. If the command
processing continued with an invalid -R path, the temporary config would have
to be explicitly discarded.
2023-12-24 00:20:38 +09:00
Yuya Nishihara
c82b2c78fd cli: inline init_workspace_loader()
In order to load command aliases from .jj/repo/config.toml, WorkspaceLoader
will be changed to be instantiated earlier with the cwd path.
2023-12-24 00:20:38 +09:00
Yuya Nishihara
5bf9e4192a cli: don't look for added/removed conflicts across old/new heads
removed_heads..added_heads won't stop if new head is added on top of non-head
commit for example.

#2729
2023-12-21 23:40:52 +09:00
Gabriel Scherer
fad511a6e5 document the use of JJ_USER and JJ_EMAIL in combination with --reset-author
Suggested-by: David Barnett <dbarnett@google.com>
2023-12-21 00:20:45 +01:00
Ilya Grigoriev
c5f76d6b4d cli untrack --help: mention that files need to be already be ignored
Make it clearer what the command does, make the error message when the file is
not ignored less of a surprise.

Also, I think it's nice to mention `.git/info/exclude`, since the path is
not trivial to remember.
2023-12-17 22:16:22 -08:00
Yuya Nishihara
87a8238bee git: turn git.auto-local-branch off by default
As far as I can see in the chat, there's no objection to changing the default,
and git.auto-local-branch = false is generally preferred.

docs/branches.md isn't updated as it would otherwise conflict with #2625. I
think the "Remotes" section will need a non-trivial rewrite.

#1136, #1862
2023-12-17 08:30:24 +09:00
Yuya Nishihara
6971ec239a tests: set git_settings.auto_local_branch where it matters 2023-12-17 08:30:24 +09:00
Essien Ita Essien
35b8dad890 Implement a rename subcommand for the branch command.
This is really a simple change that does the following in a transaction:
* Set the new branch name to point to the same commit as the old branch name.
* Set the old branch name to point to no commit (hence deleting the old name).

Before it starts, it confirms that the new branch name is not already in use.
2023-12-16 18:44:46 +00:00
Yuya Nishihara
5a466cab4c cli: ensure default remote branch is imported by "git clone"
I originally thought this would be unavoidable, but I was wrong. "jj git clone"
doesn't implicitly create any local branch if git.auto-local-branch is off, and
that's fine because the detached HEAD state is normal in jj.

That being said, Git users would expect that the main/master branch exists.
Since importing the default branch is harmless, let's create and track it no
matter if git.auto-local-branch is off.
2023-12-16 16:02:10 +09:00
Yuya Nishihara
0cb6a2f178 tests: deduplicate source repo setup in test_git_clone.rs 2023-12-16 16:02:10 +09:00
Yuya Nishihara
15c3014284 cli: colorize inline "jj branch" command hints
This is a bit different from the ordinary ui hints, but I feel the colored
output is easier to follow.
2023-12-16 07:50:15 +09:00
Yuya Nishihara
40d18bb2c9 cli: remove weird line break from the "jj branch forget" hint
The message seems a bit too long, but it doesn't make sense to insert \n
in the middle of sentence.
2023-12-16 07:50:15 +09:00
Yuya Nishihara
72d9cd019b index: extract as_composite() to trait method
The revset engine will accept abstract AsCompositeIndex type, and the
evaluated revset can be 'static if the index is behind Arc<T>.
2023-12-15 16:10:28 +09:00
Yuya Nishihara
d420002ea2 cargo: bump git2 to 0.18.1 2023-12-15 14:17:02 +09:00
Martin von Zweigbergk
90e241cc95 cli: simplify definition of workspaces in cmd_workspace_forget() 2023-12-13 08:12:49 -08:00
Martin von Zweigbergk
24b1421918 cli: move a few transaction description variables later
Now that we don't need the transaction until later, let's move the
variables closer to where they're used.
2023-12-13 08:12:49 -08:00
Martin von Zweigbergk
60fae3114e transaction: take description at end instead of start
It seems better to have the caller pass the transaction description
when we finish the transaction than when we start it. That way we have
all the information we want to include more readily available.
2023-12-13 08:12:49 -08:00
Ilya Grigoriev
872a94d1c5 cli branch track, branch untrack: document remote branches in jj help
This tries to clarify the fact that the branches must be remote and the syntax
for specifying them as globs.

Cc @yuja, https://github.com/martinvonz/jj/pull/2625#discussion_r1423379351

Here is the result (excerpt):

```
$ jj branch track --help
Start tracking given remote branches

A tracking remote branch will be imported as a local branch of the same name. Changes to it
will propagate to the existing local branch on future pulls.

Usage: jj branch track [OPTIONS] <BRANCH@REMOTE>...

Arguments:
  <BRANCH@REMOTE>...
          Remote branches to track

          By default, the specified name matches exactly. Use `glob:` prefix to select
          branches by wildcard pattern. For details, see
          https://github.com/martinvonz/jj/blob/main/docs/revsets.md#string-patterns.

          Examples: branch@remote, glob:main@*, glob:jjfan-*@upstream
```
2023-12-12 13:11:21 -08:00
Yuya Nishihara
cdcd465c79 index: move default_index_store.rs to sub directory named default_index
default_index_store.rs is relatively big, and it contains types and impls in
arbitrary order. Let's split them into sub modules. After everything moved,
mod.rs will only contain tests.
2023-12-12 08:07:52 +09:00
Martin von Zweigbergk
a88b3dd2f5 cli: print a hint about how to resolve conflicts
This prints a hint about using `jj new <first conflicted commit>` and
`jj squash` to resolve conflicts. The hint is printed whenever there
are new or resolved conflicts.

I hope this hint will be useful especially for new users so they know
which commit to resolve conflicts in first. It may not be obvious that
they should start with the bottommost one. I hope the hint will also
be useful for more more experienced user by letting them just copy the
printed command without first running `jj log` to find the right
commit..
2023-12-10 12:44:57 -08:00
Martin von Zweigbergk
2dae5f58dd cli: print a message about new and resolved conflicts
When e.g. `jj rebase` results in new conflicts, it's useful for the
user to learn about that without having to run `jj log` right
after. This patch adds reporting of new conflicts created by an
operation. It also add reporting of conflicts that were resolved or
abandoned by the operation.

There was no measurable performance impact when rebasing a single
commit in the Linux kernel repo.
2023-12-10 12:44:57 -08:00
Yuya Nishihara
a110ec6d95 cli: print failed git export reason for each ref
Not all reasons are actionable, but we print hint in common cryptic cases.
2023-12-09 23:37:00 +09:00
Yuya Nishihara
6c57ba7f21 index: rename ReadonlyIndexWrapper to DefaultReadonlyIndex
This matches the store naming: impl IndexStore for DefaultIndexStore. I also
added minimal doc comment and Debug.
2023-12-09 15:18:36 +09:00
Yuya Nishihara
a77eed648b git: have export_refs() obtain git2::Repository instance from store 2023-12-09 15:18:19 +09:00
Yuya Nishihara
25fcc3e403 workspace: consider .git symlink when generating relative git_target path
Before, an absolute path would be saved in the git_target file if .git is a
symlink. That's not wrong, but seemed a bit weird. Let's consolidate the
behavior across .git file types.
2023-12-05 14:23:59 -08:00
Yuya Nishihara
899c6375a0 git_backend: don't fully canonicalize .git symlink
Apparently, libgit2 doesn't deduce "core.bare" config from the directory name,
but gitoxide implements it correctly. So we shouldn't blindly canonicalize
the Git repository path. Fortunately, the saved git_target path isn't a fully-
canonicalized form (unless user explicitly sepcified "--git-repo ./.git"), so
we don't need a hack to remap git_target back to the symlink path.

is_colocated_git_workspace() is adjusted since the git_workdir is no longer
resolved from the fully-canonicalized repo path, at least in our code. Still we
have the ".git/.." fallback because test_init_git_colocated_symlink_gitlink()
would otherwise fail. I haven't figured out why, and the test might be actually
wrong compared to the git CLI behavior, but let's not change that for now.

Fixes #2668
2023-12-05 14:23:59 -08:00
Yuya Nishihara
32d3e24177 tests: add weirdly symlinked git repo to demonstrate "repo" tool issue
A git repo created by the "repo" tool doesn't have core.base set, which means
the "bare"-ness relies on the directory name. Gitoxide appears to parse it
correctly, whereas libgit2 doesn't. That's why the symlinked .git repo is no
longer processed as a colocated repo.

#2668
2023-12-05 14:23:59 -08:00
Yuya Nishihara
acac2cd1ee tests: extract helper function that reads "git_target" file 2023-12-05 14:23:59 -08:00
Ilya Grigoriev
1fd421f42c merge_tools.toml: add a comment to meld-3 definition
In https://github.com/martinvonz/jj/pull/2665#issuecomment-1837552283,
a user used `$base` instead of one of the `$output`s and nothing worked.
This seems like a natural mistake to make, the config is confusing.
2023-12-03 17:56:10 -08:00
Martin von Zweigbergk
1cc271441f gc: implement basic GC for Git backend
This adds an initial `jj util gc` command, which simply calls `git gc`
when using the Git backend. That should already be useful in
non-colocated repos because it's not obvious how to GC (repack) such
repos. In my own jj repo, it shrunk `.jj/repo/store/` from 2.4 GiB to
780 MiB, and `jj log --ignore-working-copy` was sped up from 157 ms to
86 ms.

I haven't added any tests because the functionality depends on having
`git` binary on the PATH, which we don't yet depend on anywhere
else. I think we'll still be able to test much of the future parts of
garbage collection without a `git` binary because the interesting
parts are about manipulating the Git repo before calling `git gc` on
it.
2023-12-03 07:40:12 -08:00
Martin von Zweigbergk
60c111645f cli: split up cmd_debug() into one function per subcommand 2023-12-02 16:37:27 -08:00
Martin von Zweigbergk
5e0b14a8bd cli: split up cmd_util() into one function per subcommand
This matches how most other commands with subcommands are handled.
2023-12-02 16:37:27 -08:00
Yuya Nishihara
1db033504c repo, workspace: remove 'static lifetime bound from initializer functions 2023-12-03 07:44:41 +09:00
Ilya Grigoriev
48d586cba0 test_abandon_command: create another test for bug 2600
See comments inline for details. Cc #2600.

In particular, I wanted to make sure these behaviors are not affected by #2646.
They don't seem to be.

The tests ended up weirder than expected because of
https://github.com/martinvonz/jj/issues/2600#issuecomment-1835418824. Even
though, right now, the behavior of tests is unaffected by that issue, the
*expected* behavior is different.
2023-12-01 17:03:44 -08:00
Ilya Grigoriev
0634dc5674 test_abandon_command: show change ids in get_log_output
Branches move around a little confusigly with `abandon`. We do want to keep
them, to test their behavior, but we can show the change id to make things
clearer.
2023-12-01 17:03:44 -08:00
Martin von Zweigbergk
a0cbe7ced0 cli: rename *Commands enums to *Command
Each instance of the enum represents a single command, so singular
`*Command` seems better. That also seems to match the examples in
clap's documentation.
2023-12-01 16:53:54 -08:00
Martin von Zweigbergk
4aad7f86ac commands: rename various *matches variables to *args
I think the `*matches` names are leftovers from before we used clap's
Derive API.
2023-12-01 16:53:54 -08:00
Yuya Nishihara
d747879aee signing: pass SigningFn by reference
write_commit() doesn't need ownership of the signing function.
2023-12-01 22:55:04 +09:00
Anton Bulakh
eb1c0ab4a2 sign: Implement a test signing backend and add a few basic tests 2023-11-30 23:36:56 +02:00
Anton Bulakh
d7229a3f90 sign: Define signing backend API and integrate it
Finished everything except actual signing backend implementation(s) and
the UI.
2023-11-30 23:36:56 +02:00
Ilya Grigoriev
bb72def464 cli rebase: tests for weird ancestry for -s and -b 2023-11-28 21:36:51 -08:00
Ilya Grigoriev
22abbbea9b cli rebase -r: add tests for weird ancestry, record a bug, fix a comment
Note that one of the new tests panics; this is a newly discovered bug.

In Git, a commit's direct parent is allowed to also be an indirect ancestor
at the same time. `jj` currently tries to prevent this situation, but does
allow it. The correctness of `rebase -r A -d descendant_of_A` currently depends
on this jj-specific behavior; we should change that.

Cc #2600
2023-11-28 21:36:51 -08:00
Chris Krycho
b4caef7fe0 cli: do not allow jj init --git in existing Git repo
Allowing `jj init --git` in an existing Git repo creates a second Git
store in `.jj/repo/store/git`, totally disconnected from the existing
Git store. This will only produce extremely confusing bugs for users,
since any operations they make in Git will *not* be reflected in the
jj repo.
2023-11-28 17:31:54 -06:00
Ilya Grigoriev
3e96bf5372 clippy: fix a nightly clippy warning 2023-11-27 16:35:47 -08:00
Yuya Nishihara
28ab9593c3 repo_path: split RepoPath into owned and borrowed types
This enables cheap str-to-RepoPath cast, which is useful when sorting and
filtering a large Vec<(String, _)> list by using matcher for example. It
will also eliminate temporary allocation by repo_path.parent().
2023-11-28 07:33:28 +09:00
Yuya Nishihara
0a1bc2ba42 repo_path: add stub RepoPathBuf type, update callers
Most RepoPath::from_internal_string() callers will be migrated to the function
that returns &RepoPath, and cloning &RepoPath won't work.
2023-11-28 07:33:28 +09:00
Yuya Nishihara
d322df0c8d matchers: make Files/PrefixMatcher constructors accept slice of borrowed paths
RepoPath will become slice type (like str), and it doesn't make sense to
require &[RepoPathBuf] here.
2023-11-28 07:33:28 +09:00