Commit graph

562 commits

Author SHA1 Message Date
Yuya Nishihara
0a8d8dad67 cli: make default log revset work without working-copy commit
Spotted while adding an error propagation path from IdPrefixContext.
2024-10-01 20:04:06 +09:00
Samuel Tardieu
baf25ba482 unsquash: deprecate in favor of squash and diffedit
Everything that could be done with `jj unsquash` can be done with
`jj squash` or `jj diffedit --preserve-descendants`.
2024-09-26 16:34:48 +02:00
Essien Ita Essien
895d53f395 Rename conflict and file revsets to conflicts and files.
See discussion thread in linked issue.

With this PR, all revset functions in [BUILTIN_FUNCTION_MAP](8d166c7642/lib/src/revset.rs (L570))
that return multiple values are either named in plural or the naming is hard to misunderstand (e.g. `reachable`)

Fixes: #4122
2024-09-24 20:02:49 +01:00
Yuya Nishihara
b8f8827914 docs: add some scripting template examples
Closes #4357
2024-09-22 07:19:50 +09:00
Vamsi Avula
a2e67bdd9b templates: add .normal_hex() for {Commit,Change}Id
This doesn't do much for CommitId but outputs the "forward" hex for
ChangeId, which can be useful to use as Gerrit Change-Id.
2024-09-17 21:11:00 -05:00
Samuel Tardieu
05c6d62c68 bookmark: add "b" alias
`jj bookmark` is a frequently used command. Its subcommands already have
one letter aliases. Defining `jj b` as an alias for `jj bookmarks` make
bookmarks really easy to use.
2024-09-17 18:24:26 +02:00
Ilya Grigoriev
5bd7588738 contributing.md: make MkDocs happier with a link 2024-09-16 16:44:31 -07:00
Samuel Tardieu
6e72b1cfb0 git: add --remote option to clone command
This makes it easier to work with multiple remotes at once while
tracking the default branch of the remote used to create the local
repository:

```shell
$ jj git clone --remote upstream https://github.com/upstream-org/repo
$ cd repo
$ jj git remote add origin git@github.com:your-org/repo
$ jj config set --repo git.fetch upstream
```

In the example above, `upstream` is the repository containing the
reference source code that you might want to patch, while `origin` is
your fork where pull-request will be pushed. The branch `main@upstream`
will be tracked.
2024-09-13 18:14:57 +02:00
Lukas Wirth
62059dd91e Fix missing word in working-copy.md 2024-09-13 13:36:52 +02:00
Lukas Wirth
1410f2bee7 docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
Ilya Grigoriev
74e3c4efe2 FAQ: Add another problem to be aware of when co-locating a repo 2024-09-12 21:46:36 -07:00
Emily Shaffer
5aa6fa5974 docs: introduce temporary governance voting process
In order for the governance working group to make progress establishing
jj's governance structure, we need the approval of the jj community.

Set up a temporary voting process to get that approval.

Additionally, set up a governance dir for other governance-related
documentation to sit in.

Later, when we have a permanent governance structure and enough policy
to let the community make changes without needing the governance working
group, we can delete this document.
2024-09-12 15:19:46 -07:00
Philip Metzger
5f84c73b5a RFC: Formalize our commit style to mention that we don't use conventional commits.
It's the simple _when in Rome, do as the Romans do_ rule.
2024-09-12 16:52:02 +02:00
Martin von Zweigbergk
1aa2aec141 bookmarks: update some leftover uses of the word "branch" 2024-09-11 19:19:31 -07:00
Philip Metzger
d9c68e08b1 everything: Rename branches to bookmarks
Jujutsu's branches do not behave like Git branches, which is a major
hurdle for people adopting it from Git. They rather behave like
Mercurial's (hg) bookmarks. 

We've had multiple discussions about it in the last ~1.5 years about this rename in the Discord, 
where multiple people agreed that this _false_ familiarity does not help anyone. Initially we were 
reluctant to do it but overtime, more and more users agreed that `bookmark` was a better for name 
the current mechanism. This may be hard break for current `jj branch` users, but it will immensly 
help Jujutsu's future, by defining it as our first own term. The `[experimental-moving-branches]` 
config option is currently left alone, to force not another large config update for
users, since the last time this happened was when `jj log -T show` was removed, which immediately 
resulted in breaking users and introduced soft deprecations.

This name change will also make it easier to introduce Topics (#3402) as _topological branches_ 
with a easier model. 

This was mostly done via LSP, ripgrep and sed and a whole bunch of manual changes either from
me being lazy or thankfully pointed out by reviewers.
2024-09-11 18:54:45 +02:00
Stephen Jennings
12ec2212fb faq: Add "Should I co-locate my repository?" 2024-09-09 09:42:02 -07:00
Martin von Zweigbergk
f36f4ad257 cli: make paths to auto-track configurable, add jj track
It's a pretty frequent request to have support for turning off
auto-tracking of new files and to have a command to manually track
them instead. This patch adds a `snapshot.auto-track` config to decide
which paths to auto-track (defaults to `all()`). It also adds a `jj
track` command to manually track the untracked paths.

This patch does not include displaying the untracked paths in `jj
status`, so for now this is probably only useful in colocated repos
where you can run `git status` to find the untracked files.

#323
2024-09-09 07:49:55 -07:00
Martin von Zweigbergk
fee706dfea signing: allow disabling by setting backend to "none"
We don't seem to have a way to override the config to disable
signing. This patch lets you do that by setting
`signing.backend="none"`.
2024-09-05 21:02:22 -07:00
Martin von Zweigbergk
a0fae76622 cli: rename obslog to evolution-log/evolog
It seems everyone agrees that `obslog` is not an intuitive name. There
was some discussion about alternatives in #3592 and on #4146. The
alternatives included `evolution`, `evolutionlog`, `evolog`,
`rewritelog`, `revlog`, and `changelog`. It seemed like
`evolution-log`/`evolog` was the most popular option. That also
matches the command's current help text ("Show how a change has
evolved over time").
2024-09-05 13:45:17 -07:00
Ethan Brierley
3fcb6eedfd docs(roadmap): minor typo, as should be ask 2024-09-04 20:07:04 +02:00
Martin von Zweigbergk
7d274a911e docs: add link to roadmap from docs main page
The roadmap seems like something users might want to read soon after
they find the project, so a link from the main page seems useful to
me.
2024-09-04 00:03:32 -07:00
Martin von Zweigbergk
250a28b5a5 docs: add a roadmap 2024-09-03 21:42:29 -07:00
Ilya Grigoriev
065870160b docs: minor fix to Markdown formatting
MkDocs did not render this list in
https://martinvonz.github.io/jj/prerelease/config/#node-style properly
before.

I don't understand the reason; we have other lists that are formatted
similarly to how this one was, and they look fine in MkDocs. This might
be a bug in one of the MkDocs extensions for lists that we use.
2024-09-03 21:31:20 -07:00
Stephen Jennings
1c672d7563 docs: Add FAQ for keeping changes to tracked files
The question "How do I avoid committing changes to files?" comes up a lot in
chat, and the solution is not obvious. It will be useful to have a description
with an example we can link to.

The wording of the similar question "How can I keep my scratch files in the
repository?" was tweaked to emphasize the difference between keeping untracked
files in the workspace and keeping changes tracked files out of published
history.
2024-09-03 17:23:58 -07:00
Martin von Zweigbergk
cc15ecf7c7 op log: change "resolve concurrent" to "reconcile divergent"
"Concurrent" operations are not necessarily actually concurrent, so
"divergent" seems like a better name. And "reconcile" seems like a
better term for merging them, though we also sometimes use "merge".
2024-08-30 21:56:11 -07:00
Yuya Nishihara
5af906d924 cli: change default inline threshold of color-words diffs
I played with max-inline-alternation = 3 for a couple of weeks, and it's pretty
good. I think somewhere between 2 and 4 is good default because one or two
remove + add sequences are easy to parse.
2024-08-28 10:33:33 +09:00
Yuya Nishihara
6b65f8abec cli: move "untrack" to "file" subcommand
I don't think "jj untrack" is frequently used, and I think it is a "file"
command rather than "workspace".
2024-08-26 01:19:15 +09:00
Yuya Nishihara
842ebe7f92 docs: add missing single quote to revset-aliases example
Spotted by xzfc.
2024-08-25 23:16:29 +09:00
Martin von Zweigbergk
b05593fdf5 docs: add git ls-files to command comparison table
This came up in #4323.
2024-08-22 22:30:31 -07:00
Yuya Nishihara
a83dadd5a9 diff: add option to display complex color-words diffs without inlining
In this patch, I use the number of adds<->removes alternation as a threshold,
which approximates the visual complexity of diff hunks. I don't think user can
choose the threshold intuitively, but we need a config knob to try out some.
I set `max-inline-alternation = 3` locally. 0 and 1 mean "disable inlining"
and "inline adds-only/removes-only lines" respectively.

I've added "diff.<format>" config namespace assuming "ui.diff" will be
reorganized as "ui.diff-formatter" or something. #3327

Some other metrics I've tried:
```
// Per-line alternation. This also works well, but can't measure complexity of
// changes across lines.
fn count_max_diff_alternation_per_line(diff_lines: &[DiffLine]) -> usize {
    diff_lines
        .iter()
        .map(|line| {
            let sides = line.hunks.iter().map(|&(side, _)| side);
            sides
                .filter(|&side| side != DiffLineHunkSide::Both)
                .dedup() // omit e.g. left->both->left
                .count()
        })
        .max()
        .unwrap_or(0)
}

// Per-line occupancy of changes. Large diffs don't always look complex.
fn max_diff_token_ratio_per_line(diff_lines: &[DiffLine]) -> f32 {
    diff_lines
        .iter()
        .filter_map(|line| {
            let [both_len, left_len, right_len] =
                line.hunks.iter().fold([0, 0, 0], |mut acc, (side, data)| {
                    let index = match side {
                        DiffLineHunkSide::Both => 0,
                        DiffLineHunkSide::Left => 1,
                        DiffLineHunkSide::Right => 2,
                    };
                    acc[index] += data.len();
                    acc
                });
            // left/right-only change is readable
            (left_len != 0 && right_len != 0).then(|| {
                let diff_len = left_len + right_len;
                let total_len = both_len + left_len + right_len;
                (diff_len as f32) / (total_len as f32)
            })
        })
        .reduce(f32::max)
        .unwrap_or(0.0)
}

// Total occupancy of changes. Large diffs don't always look complex.
fn total_change_ratio(diff_lines: &[DiffLine]) -> f32 {
    let (diff_len, total_len) = diff_lines
        .iter()
        .flat_map(|line| &line.hunks)
        .fold((0, 0), |(diff_len, total_len), (side, data)| {
            let l = data.len();
            match side {
                DiffLineHunkSide::Both => (diff_len, total_len + l),
                DiffLineHunkSide::Left => (diff_len + l, total_len + l),
                DiffLineHunkSide::Right => (diff_len + l, total_len + l),
            }
        });
    (diff_len as f32) / (total_len as f32)
}
```
2024-08-21 17:48:52 +09:00
Daniel Raniz Raneland
3d5c5b03de Added docs about installation under Gentoo Linux 2024-08-20 22:19:09 -07:00
Marie Ramlow
e3fcae2152 merge_tools.toml: add VSCodium as a merge tool
[VSCodium](https://vscodium.com/) is a free/libre distribution of
Microsoft's Visual Studio Code editor, it's functionally more or less
the same, but distributed under a FOSS license, unlike VS Code.

This adds VSCodium as a merge tool.
2024-08-19 22:37:00 -07:00
Essien Ita Essien
a6d8009097 Define builtin_immutable_heads() as a default revset alias.
* Add `builtin_immutable_heads()` in the `revsets.toml`.
* Redefine `immutable_heads()` in terms of `builtin_immutable_heads()`
* Warn if user redefines `builtin_immutable_heads()`, `mutable()` or
  `immutable()`.
* Update module constant in revset_util.rs from BUILTIN_IMMUTABLE_HEADS
  to USER_IMMUTABLE_HEADS to avoid confusion since it points at
  `immutable_heads()` **and** we now have a revset-alias
  literally named `builtin_immutable_heads()`.
* Add unittest
* Update CHANGELOG
* Update documentation.

Fixes: #4162
2024-08-14 11:32:16 +01:00
Aaron Bull Schaefer
e803bed845 config: expand tilde in ssh key filepaths
Add home directory expansion for SSH key filepaths. This allows the
`signing.key` configuration value to work more universally across both
Linux and macOS without requiring an absolute path.

This moved and renamed the previous `expand_git_path` function to a more
generic location, and the prior use was updated accordingly.
2024-08-13 08:06:43 -07:00
Ilya Grigoriev
206c0cf830 docs: document how to compile a statically linked binary on Mac
I feel like this is worth documenting, as it shouldn't require
Homebrew.
2024-08-11 20:10:37 -07:00
Ilya Grigoriev
b2123282e8 tutorial: link to Steve Klabnik's tutorial, mention jj log -r ::
I was thinking of updating the tutorial in #4168, but conversations like [this
one on
Discord](https://discord.com/channels/968932220549103686/968932220549103689/1269803837070377076)
suggest that many people aren't reading it anyway.

So, this is an attempt to quickly patch up the most relevant things before the
upcoming release.
2024-08-06 11:27:08 -07:00
Martin von Zweigbergk
417f19d58a docs: minor updates to description of branch conflicts
Closes #4220.
2024-08-05 18:20:37 -07:00
Fedor Sheremetyev
c43096ba96 docs: Fix example with Git conflicts markers 2024-08-02 10:36:38 -07:00
Martin von Zweigbergk
5b2259445e FAQ: remove workaround for fixed bug (#2476) 2024-08-01 09:07:32 -07:00
Stephen Jennings
6c41b1bef8 revset: add author_date and committer_date revset functions
Author dates and committer dates can be filtered like so:

    committer_date(before:"1 hour ago") # more than 1 hour ago
    committer_date(after:"1 hour ago")  # 1 hour ago or less

A date range can be created by combining revsets. For example, to see any
revisions committed yesterday:

    committer_date(after:"yesterday") & committer_date(before:"today")
2024-08-01 09:04:07 -07:00
Danny Hooper
89f5d16dc0 cli jj fix: add ability to configure multiple tools for different filesets
The high level changes include:
 - Reworking `fix_file_ids()` to loop over multiple candidate tools per file,
   piping file content between them. Only the final file content is written to
   the store, and content is no longer read for changed files that don't match
   any of the configured patterns.
 - New struct `ToolsConfig` to represent the parsed/validated configuration.
 - New function `get_tools_config()` to create a `ToolsConfig` from a `Config`.
 - New tests; the only old behavior that has changed is that we don't require
   `fix.tool-command` if `fix.tools` defines one or more tools. The general
   approach to validating the config is to fail early if anything is weird.

Co-Authored-By: Josh Steadmon <steadmon@google.com>
2024-07-25 13:40:18 -05:00
Yuya Nishihara
d6e97883df cli: port description template to templater
This implements a building block of "signed-off-by line" #1399 and "commit
--verbose" #1946. We'll probably need an easy way to customize the diff part,
but I'm not sure if it can be as simple as a template alias function. User
might want to embed diffs without "JJ: " prefixes?

Perhaps, we can deprecate "ui.default-description", but it's not addressed in
this patch. It could be replaced with "default_description" template alias,
but we might want to configure default per command. Suppose we add a default
"backout_description" template, it would have to be rendered against the
source commit, not the newly-created backout commit.

The template key is named as "draft_commit_description" because it is the
template to generate an editor template. "templates.commit_description_template"
sounds a bit odd.

There's one minor behavior change: the default description is now terminated
by "\n".

Closes #1354
2024-07-25 22:39:00 +09:00
Yuya Nishihara
8fec7500c3 cli: enable fileset by default
I've tested it for months and found no problems.
2024-07-24 10:49:46 +09:00
Stephen Jennings
03b6d380f5 git: add git.private-commits setting for preventing commits from being pushed
The user can define the setting `git.private-commits` as they desire. For
example:

    git.private-commits = 'description(glob:"wip:*")'

If any commits are in this revset, then the push is aborted.

If a commit would be private but already exists on the remote, then it does
not block pushes, nor do its descendents block pushes unless they are also
contained in `git.private-commits`.

Closes #3376
2024-07-23 08:45:51 -07:00
Julien Vincent
feceb622f1 Add hunk.nvim to list of community tools 2024-07-22 15:29:54 -06:00
Yuya Nishihara
ddc601fbf9 str_util: add regex pattern
This patch adds minimal support for the regex pattern. We might have to add
"regex-i:" for completeness, but it can be achieved by "regex:'(?i)..'".
2024-07-22 12:00:52 +09:00
Yuya Nishihara
5649ee4f45 fileset: parse glob characters as identifier
It's inconvenient that we have to quote glob patterns as 'glob:"*.rs"'. Suppose
filesets are usually specified in shell, it's better to allow unquoted strings
if possible. This change also means we'll probably abandon #2101 "make the
parsing of string arguments stricter."

Note that we can no longer introduce ? operator or [] subscript syntax in
filesets.

Closes #4053
2024-07-18 13:49:10 +09:00
Yuya Nishihara
895eead4b8 revset: add diff_contains(text[, files]) to search diffs
The text pattern is applied prior to comparison as we do in Mercurial. This
might affect hunk selection, but is much faster than computing diff of full
file contents. For example, the following hunk wouldn't be caught by
diff_contains("a") because the line "b\n" is filtered out:

    - a
      b
    + a

Closes #2933
2024-07-18 01:01:16 +09:00
Vladimír Čunát
0c8f881fcd docs/git-comparison.md: update the Signed_commits bullet 2024-07-17 17:12:34 +02:00
Yuya Nishihara
d1912bf016 templater: add commit.diff().<format>() methods
This patch adds TreeDiff template type to host formatting options. The main
reason of this API design is that diff formats have various incompatible
parameters, so a single .diff(files, format[, options..]) method would become
messy pretty quickly. Another reason is that we can probably add custom
summary templating support as diff.files().map(|file| file.path()..).

RepoPathUiConverter is passed to templater explicitly because the one stored
in RevsetParseContext is behind Option<_>.
2024-07-17 18:52:49 +09:00