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

177 commits

Author SHA1 Message Date
Ilya Grigoriev
95949e8011 test_abandon_command: rename test 2023-11-25 21:36:35 -08:00
Yuya Nishihara
4f2503cbce cli: show hint of non-tracking remote branches on "jj init --git-repo"
If the existing git repo contains local and remote branches of the same name,
one of the remote branches is probably a tracking remote branch. Let's show
a hint how to set up tracking branches. The tracking state could be derived
from .git/config, but doing that automatically might cause another issue like
#1862, which could have been mitigated by git.auto-local-branch = false.
2023-11-25 16:46:10 +09:00
Ilya Grigoriev
811ac5ff23 cli new: have --no-edit print description of the new commit 2023-11-23 11:15:38 -08:00
Ilya Grigoriev
e33f57a0f5 cli new: add --no-edit option
This allows, for example, creating a merge commit with `jj new a b --no-edit -m Merge`, without
affecting the working copy.
2023-11-23 11:15:38 -08:00
Ilya Grigoriev
aa08de30c7 cli new: Make -r, --before, and --after repeatable
Repeating these is a no-op. This allows:

```shell
jj new -r a -r b # Equivalent to jj new a b
jj new --before a --before b  # Equivalent to jj new a b --before
```

I keep typing the latter and getting an annoying error.
2023-11-23 11:15:38 -08:00
Ilya Grigoriev
22ad4d7599 test_abandon_command: test avoidance of simultaneous direct and indirect descendants
This is similar to the following test:

5186066cf5/cli/tests/test_rebase_command.rs (L264-L269) 

from https://github.com/martinvonz/jj/pull/538.
2023-11-19 16:37:49 -08:00
Ilya Grigoriev
e5cfada7e2 test_abandon_command: remove obsolete TODO
This was fixed in 7c8f66ab0, I believe.
2023-11-19 16:37:49 -08:00
Martin von Zweigbergk
c2d5e3d343 clippy: fix new issues spotted by nightly version 2023-11-16 10:20:07 -08:00
Yuya Nishihara
9533177422 cli: include branch name in non-fast-forwardable error
Just like the other errors.
2023-11-11 07:03:31 +09:00
Yuya Nishihara
27751b0142 tests: add test for moving conflicting branch to one of descendants 2023-11-11 07:03:31 +09:00
Yuya Nishihara
0d21578846 cli: disallow to create new branch by "jj branch set"
Per discussion in https://github.com/martinvonz/jj/discussions/2555. I'm
okay with either way, but it's confusing if we had "branch create" and
"branch set" and both of these could create a new branch.
2023-11-11 07:03:31 +09:00
Yuya Nishihara
aca2a3cf93 tests: don't create new branch by "jj branch set" 2023-11-11 07:03:31 +09:00
Łukasz Kurowski
57d7aeab5e cli: generate commit template after selecting changes
Renamed `description_template_for_commit` to
`description_template_for_describe` since it's only used in
`cmd_describe`.

Renamed `description_template_for_cmd_split` to
`description_template_for_commit` and modified to accomodate empty
`intro` argument.

Fixes #2439.
2023-11-09 15:10:25 +01:00
Yuya Nishihara
70479a712b cli: include branch names in bulk branch creation/update warning
This will probably help notice missing -r flag. Maybe we can also warn if
one of the branch names looks like a revset.

https://github.com/martinvonz/jj/discussions/2555
2023-11-09 15:38:22 +09:00
Yuya Nishihara
a6aa8aa4f4 tests: add test for moving branch forward and backward 2023-11-09 15:38:22 +09:00
Yuya Nishihara
2ac9865ce7 revset: exclude @git branches from remote_branches()
As discussed in Discord, it's less useful if remote_branches() included
Git-tracking branches. Users wouldn't consider the backing Git repo as
a remote.

We could allow explicit 'remote_branches(remote=exact:"git")' query by changing
the default remote pattern to something like 'remote=~exact:"git"'. I don't
know which will be better overall, but we don't have support for negative
patterns anyway.
2023-11-08 07:34:30 +09:00
Yuya Nishihara
f1898a31b5 merge: simply print interleaved conflict values in debug output
We could apply that for the resolved case, but Resolved/Conflicted label
seems more useful than just printing Merge([value]).
2023-11-06 07:21:06 +09:00
Yuya Nishihara
b07b370ed3 merge: simply generate content hash from interleaved values 2023-11-06 07:21:06 +09:00
Yuya Nishihara
d8a7822c38 merge_tools: do not follow or change permission of symlinks
Fixes #2525.
2023-11-06 07:20:52 +09:00
Austin Seipp
e1193db4cf cli: support multiple --revision arguments to workspace add
Summary: A natural extension of the existing support, as suggested by Scott
Olson. Closes #2496.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I91c9c8c377ad67ccde7945ed41af6c79
2023-11-04 10:26:08 -05:00
Yuya Nishihara
c88e69ad6f git_backend: replace git2::Repository with gix::Repository
My gut feeling is that gitoxide aims to be more transparent than libgit2. We'll
need to know more about the underlying Git data model.

Random comments on gix API:

 * gix::Repository provides API similar to git2::Repository, but has less
   "convenient" functions. For example, we need to use .find_object() +
   .try_to/into_<kind>() instead of .find_<kind>().
 * gix::Object, Blob, etc. own raw data as bytes. gix::object and gix::objs
   types provide high-level views on such data.
 * Tree building is pretty low-level compared to git2.
 * gix leverages bstr (i.e. bytes) extensively.

It's probably not difficult to migrate git::import/export_refs(). It might
help eliminate the startup overhead of libssl initialization. The gix-based
GitBackend appears to be a bit faster, but that wouldn't practically matter.

#2316
2023-11-02 19:33:06 +09:00
Yuya Nishihara
f89f2f9e7d cli: add "branch list [NAMES]..." filter
Like "jj log PATHS...", unmatched name isn't an error. I don't think
"jj branch list glob:'push-*'" should fail just because there are no in-flight
PR branches.
2023-11-01 08:38:55 -07:00
Isabella Basso
749d8bb15a git: preserve HEAD when possible
Closes: #2210
2023-11-01 08:23:52 -03:00
Ilya Grigoriev
8bc3f5fd67 cli rebase: Allow jj rebase -r to rebase a commit onto a descendant
#1188

There are some additional test changes because children and descendants are now
rebased before the commit itself.
2023-10-30 10:56:27 -07:00
Martin von Zweigbergk
23a0baba14 cli: make jj workspace add preserve all parents of current workspace 2023-10-29 21:53:29 -07:00
Ilya Grigoriev
b482898924 immutable commits: remove the hint if trying to edit the root commit
The hint is a bit misleading in this case. I also changed the message slightly.
2023-10-29 21:13:39 -07:00
Ilya Grigoriev
ebb6b942ac cli new: have --before/--after respect immutable commits
I wasn't very careful to make the function
pretty; I'm planning to refactor it anyway as
part of implementing `rebase --before` and
`rebase --after`.
2023-10-29 21:13:39 -07:00
Ilya Grigoriev
2571169251 clippy: run cargo clippy --fix --workspace with recent nightly 2023-10-29 20:19:44 -07:00
Yuya Nishihara
0e14a1f04d templater: add local/remote_branches keywords 2023-10-28 11:03:23 +09:00
Yuya Nishihara
01d474563e templater: make branches, tags, git_refs, and git_head return list type
I'm not going to change the default output, but this allows us to highlight
or dim only the @remote component.
2023-10-28 05:29:50 +09:00
Ilya Grigoriev
eeb93cc8be cli change id templates: make "hidden" override "divergent"
See the test changes in `test_undo.rs` for motivation. This matters rarely, but
seems to be better.
2023-10-26 17:58:13 -07:00
Ilya Grigoriev
1733ae22c7 cli templates: include info on divergent change ids in short commit template
Fixes #2411
2023-10-26 17:58:13 -07:00
Ilya Grigoriev
6a128f56ed cli: rebase descendants earlier for jj diffedit and jj restore
Makes sure that, at the point the commit summary for the new commit is written,
the original commit that is being rewritten is already abandoned. Otherwise,
once we show divergent change ids (in a subsequent commit) in the short commit
template, the commits would be shown as divergent.

This also has an effect on whether branches are displayed next to the commit;
the changes in test_resotre_command happen because, now, the branch is properly
propagated to the restored commit before its summary is displayed.
2023-10-26 17:58:13 -07:00
Yuya Nishihara
2874a69faf tests: migrate most tests from test_templater.rs
test_templater_alias(), test_templater_alias_override(), and
test_templater_bad_alias_decl() aren't moved since they also test config loading
and error formatting. The first test in test_templater_parse_error() is left for
the same reason. test_templater_upper_lower() depends on the commit templater.
2023-10-27 05:30:53 +09:00
Yuya Nishihara
957360dc83 tests: use color formatter in core template tests
test_templater_label_function() is migrated as example.
2023-10-27 05:30:53 +09:00
Yuya Nishihara
96f8ca5d54 tests: add minimal template language and test helpers
I don't think many of the tests in test_templater.rs should use "jj log" command
as they check very specific template syntax and function behaviors. Let's move
them to in-module tests. We could add a separate test file, but we would have
to export a couple of templater macros.

test_templater_timestamp_method() is migrated as example.
2023-10-27 05:30:53 +09:00
Yuya Nishihara
b455335983 tests: move test_templater_branches() to test_commit_template.rs
It's not testing the core templater functionality.
2023-10-27 05:30:53 +09:00
Yuya Nishihara
1bfe5b5b56 cli: add string pattern support to "git push --branch"
Since "jj git fetch --branch" supports glob patterns, users would expect that
"jj git push --branch glob:.." also works.

The error handling bits are copied from "branch" sub commands. We might want to
extract it to a common helper function, but I haven't figured out a reasonable
boundary point yet.
2023-10-26 04:51:17 +09:00
Ilya Grigoriev
5e407982b1 cli templates: include hidden (AKA abandoned) status in short commit template
This is mainly relevant for `jj abandon` and `jj branch list`. #2411
2023-10-24 12:37:26 -07:00
Ilya Grigoriev
94c55d6152 test_abandon_command: add test where a commit is abandoned twice 2023-10-24 12:37:26 -07:00
Yuya Nishihara
560b63544a cli: parse "git fetch --branch" parameter as string pattern
Even though "*" can't be used as a branch name to fetch, it should be better
to explicitly enable glob matching like the other commands.
2023-10-25 03:58:48 +09:00
Martin von Zweigbergk
8157d4ff63 merge: materialize conflicts in executable files like regular files
AFAICT, all callers of `Merge::to_file_merge()` are already well
prepared for working with executable files. It's called from these
places:

* `local_working_copy.rs`: Materialized conflicts are correctly
  updated using `Merge::with_new_file_ids()`.

* `merge_tools/`: Same as above.

* `cmd_cat()`: We already ignore the executable bit when we print
  non-conflicted files, so it makes sense to also ignore it for
  conflicted files.

* `git_diff_part()`: We print all conflicts with mode "100644" (the
  mode for regular files). Maybe it's best to use "100755" for
  conflicts that are unambiguously executable, or maybe it's better to
  use a fake mode like "000000" for all conflicts. Either way, the
  current behavior seems fine.

* `diff_content()`: We use the diff content in various diff
  formats. We could add more detail about the executable bits in some
  of them, but I think the current output is fine. For example,
  instead of our current "Created conflict in my-file", we could say
  "Created conflict in executable file my-file" or "Created conflict
  in ambiguously executable file my-file". That's getting verbose,
  though.

So, I think all we need to do is to make `Merge::to_file_merge()` not
require its inputs to be non-executable.

Closes #1279.
2023-10-24 06:45:45 -07:00
Martin von Zweigbergk
daa23173c5 cli: add a jj debug tree command for printing the tree
I'm about to make conflicts also get materialized in executable
files. We'll lose some of the test coverage in `test_chmod_command.rs`
then, because the those tests rely on the materialized content to
describe the executable bits. So this commit adds a debug command for
printing tree values and uses that in the tests.
2023-10-24 06:45:45 -07:00
Yuya Nishihara
5543f7a11c refs: merge tracking state of remote branches
Otherwise "jj op undo" can't roll back tracking states (whereas "op restore"
can.)
2023-10-24 07:13:58 +09:00
Yuya Nishihara
baef7f1da2 cli: show stats if multiple branches are tracked/untracked
Just like the other branch commands.
2023-10-24 06:46:17 +09:00
Yuya Nishihara
d7f504c98c cli: allow to select branches to track/untrack by string pattern 2023-10-24 06:46:17 +09:00
Yuya Nishihara
d43704c978 cli: do not error out on re-track/untrack, show warning instead
If we add glob support, users will probably want to do something like
'jj branch untrack glob:"*@origin"'. It would be annoying if the command
failed just because one of the remote branches has already been untracked.
Since branch tracking/untracking is idempotent, it's safe to continue in
those cases.
2023-10-24 06:46:17 +09:00
Yuya Nishihara
8dbe12da2a cli: deprecate branch delete/forget --glob option in favor of glob: syntax
I'm not going to remove --glob anytime soon, but I won't add --glob option to
new commands.
2023-10-22 04:07:49 +09:00
Yuya Nishihara
c3f167e6cc cli: add kind:pattern syntax to branch delete/forget commands
The parse rule is lax compared to revset. We could require the pattern to be
quoted, but that would mean glob patterns have to be quoted like 'glob:"foo*"'.
2023-10-22 04:07:49 +09:00
Yuya Nishihara
eb2f2783df cli: use StringPattern to find branches to delete/forget
The error message for unmatched patterns is adjusted so that it can be applied
to both exact and glob patterns.
2023-10-22 04:07:49 +09:00