mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-24 12:48:55 +00:00
cli: rename jj edit
to jj touchup
This commit is contained in:
parent
fc4b109e5b
commit
9c55d98842
7 changed files with 28 additions and 22 deletions
|
@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* The [`$NO_COLOR` environment variable](https://no-color.org/) no longer
|
||||
overrides the `ui.color` configuration if explicitly set.
|
||||
|
||||
* `jj edit` has been renamed to `jj touchup`.
|
||||
|
||||
* `jj git push` no longer aborts if you attempt to push an open commit (but it
|
||||
now aborts if a commit does not have a description).
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ updated. So will the working copy if it points to a rebased commit.
|
|||
### Comprehensive support for rewriting history
|
||||
|
||||
Besides the usual rebase command, there's `jj describe` for editing the
|
||||
description (commit message) of an arbitrary commit. There's also `jj edit`,
|
||||
description (commit message) of an arbitrary commit. There's also `jj touchup`,
|
||||
which lets you edit the changes in a commit without checking it out. To split
|
||||
a commit into two, use `jj split`. You can even move part of the changes in a
|
||||
commit to any other commit using `jj move`.
|
||||
|
|
|
@ -240,7 +240,7 @@ parent.
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Interactively edit the diff in a given change</td>
|
||||
<td><code>jj edit -r <revision></code></td>
|
||||
<td><code>jj touchup -r <revision></code></td>
|
||||
<td>Not supported (can be emulated with the "edit" action in
|
||||
<code>git rebase -i</code>)</td>
|
||||
</tr>
|
||||
|
|
|
@ -386,10 +386,10 @@ the parent change, even if they touch the same word, and it won't cause any
|
|||
conflicts.
|
||||
|
||||
Let's try one final command for changing the contents of an exiting commit. That
|
||||
command is `jj edit`, which lets you edit the contents of a commit without
|
||||
command is `jj touchup`, which lets you edit the contents of a commit without
|
||||
checking it out.
|
||||
```shell script
|
||||
$ jj edit -r @--
|
||||
$ jj touchup -r @--
|
||||
Created 2423c134ea70 ABC
|
||||
Rebased 2 descendant commits
|
||||
Working copy now at: d31c52e8ca41 (no description set)
|
||||
|
@ -399,10 +399,10 @@ When Meld starts, edit the right side by e.g. adding something to the first
|
|||
line. Then close Meld. You can now inspect the rewritten commit with
|
||||
`jj diff -r @--` again and you should see your addition to the first line.
|
||||
Unlike `jj squash -i`, which left the content state of the commit unchanged,
|
||||
`jj edit` (typically) results in a different state, which means that descendant
|
||||
`jj touchup` (typically) results in a different state, which means that descendant
|
||||
commits may have conflicts.
|
||||
|
||||
Other commands for rewriting contents of existing commits are `jj restore -i`,
|
||||
`jj split`, `jj unsquash -i`. Now that you've seen how `jj squash -i` and
|
||||
`jj edit` work, you can hopefully figure out how those work (with the help of
|
||||
`jj touchup` work, you can hopefully figure out how those work (with the help of
|
||||
the instructions in the diff).
|
||||
|
|
|
@ -1132,7 +1132,7 @@ enum Commands {
|
|||
Squash(SquashArgs),
|
||||
Unsquash(UnsquashArgs),
|
||||
Restore(RestoreArgs),
|
||||
Edit(EditArgs),
|
||||
Touchup(TouchupArgs),
|
||||
Split(SplitArgs),
|
||||
Merge(MergeArgs),
|
||||
Rebase(RebaseArgs),
|
||||
|
@ -1513,7 +1513,7 @@ struct RestoreArgs {
|
|||
paths: Vec<String>,
|
||||
}
|
||||
|
||||
/// Edit the content changes in a revision
|
||||
/// Touch up the content changes in a revision
|
||||
///
|
||||
/// Starts a diff editor (`meld` by default) on the changes in the revision.
|
||||
/// Edit the right side of the diff until it looks the way you want. Once you
|
||||
|
@ -1522,8 +1522,8 @@ struct RestoreArgs {
|
|||
/// unsquash -i` if you instead want to move changes into or out of the parent
|
||||
/// revision.
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct EditArgs {
|
||||
/// The revision to edit
|
||||
struct TouchupArgs {
|
||||
/// The revision to touch up
|
||||
#[clap(long, short, default_value = "@")]
|
||||
revision: String,
|
||||
}
|
||||
|
@ -3731,7 +3731,11 @@ side. If you don't make any changes, then the operation will be aborted.
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn cmd_edit(ui: &mut Ui, command: &CommandHelper, args: &EditArgs) -> Result<(), CommandError> {
|
||||
fn cmd_touchup(
|
||||
ui: &mut Ui,
|
||||
command: &CommandHelper,
|
||||
args: &TouchupArgs,
|
||||
) -> Result<(), CommandError> {
|
||||
let mut workspace_command = command.workspace_helper(ui)?;
|
||||
let commit = workspace_command.resolve_single_rev(ui, &args.revision)?;
|
||||
workspace_command.check_rewriteable(&commit)?;
|
||||
|
@ -5278,7 +5282,7 @@ where
|
|||
Commands::Squash(sub_args) => cmd_squash(ui, &command_helper, sub_args),
|
||||
Commands::Unsquash(sub_args) => cmd_unsquash(ui, &command_helper, sub_args),
|
||||
Commands::Restore(sub_args) => cmd_restore(ui, &command_helper, sub_args),
|
||||
Commands::Edit(sub_args) => cmd_edit(ui, &command_helper, sub_args),
|
||||
Commands::Touchup(sub_args) => cmd_touchup(ui, &command_helper, sub_args),
|
||||
Commands::Split(sub_args) => cmd_split(ui, &command_helper, sub_args),
|
||||
Commands::Merge(sub_args) => cmd_merge(ui, &command_helper, sub_args),
|
||||
Commands::Rebase(sub_args) => cmd_rebase(ui, &command_helper, sub_args),
|
||||
|
|
|
@ -149,16 +149,16 @@ fn test_help() {
|
|||
// Test that global options are separated out in the help output
|
||||
let test_env = TestEnvironment::default();
|
||||
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["edit", "-h"]);
|
||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["touchup", "-h"]);
|
||||
insta::assert_snapshot!(stdout.replace(".exe", ""), @r###"
|
||||
jj-edit
|
||||
Edit the content changes in a revision
|
||||
jj-touchup
|
||||
Touch up the content changes in a revision
|
||||
|
||||
USAGE:
|
||||
jj edit [OPTIONS]
|
||||
jj touchup [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
-r, --revision <REVISION> The revision to edit [default: @]
|
||||
-r, --revision <REVISION> The revision to touch up [default: @]
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--at-operation <AT_OPERATION> Operation to load the repo at [default: @] [aliases: at-op]
|
||||
|
|
|
@ -37,7 +37,7 @@ fn test_edit() {
|
|||
"files-before file1 file2\0files-after JJ-INSTRUCTIONS file2",
|
||||
)
|
||||
.unwrap();
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["edit"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["touchup"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Nothing changed.
|
||||
"###);
|
||||
|
@ -49,7 +49,7 @@ fn test_edit() {
|
|||
|
||||
// Nothing happens if the diff-editor exits with an error
|
||||
std::fs::write(&edit_script, "rm file2\0fail").unwrap();
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["edit"]);
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["touchup"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: Failed to edit diff: The diff tool exited with a non-zero code
|
||||
"###);
|
||||
|
@ -61,7 +61,7 @@ fn test_edit() {
|
|||
|
||||
// Can edit changes to individual files
|
||||
std::fs::write(&edit_script, "reset file2").unwrap();
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["edit"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["touchup"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Created 8c79910b5033 (no description set)
|
||||
Working copy now at: 8c79910b5033 (no description set)
|
||||
|
@ -75,7 +75,7 @@ fn test_edit() {
|
|||
// Changes to a commit are propagated to descendants
|
||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||
std::fs::write(&edit_script, "write file3\nmodified\n").unwrap();
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["edit", "-r", "@-"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["touchup", "-r", "@-"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Created 472de2debaff (no description set)
|
||||
Rebased 1 descendant commits
|
||||
|
@ -126,7 +126,7 @@ fn test_edit_merge() {
|
|||
"files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1",
|
||||
)
|
||||
.unwrap();
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["edit", "-r", "@-"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["touchup", "-r", "@-"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Created 608f32ad9e19 merge
|
||||
Rebased 1 descendant commits
|
Loading…
Reference in a new issue