forked from mirrors/jj
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
|
* The [`$NO_COLOR` environment variable](https://no-color.org/) no longer
|
||||||
overrides the `ui.color` configuration if explicitly set.
|
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
|
* `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).
|
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
|
### Comprehensive support for rewriting history
|
||||||
|
|
||||||
Besides the usual rebase command, there's `jj describe` for editing the
|
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
|
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
|
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`.
|
commit to any other commit using `jj move`.
|
||||||
|
|
|
@ -240,7 +240,7 @@ parent.
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Interactively edit the diff in a given change</td>
|
<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
|
<td>Not supported (can be emulated with the "edit" action in
|
||||||
<code>git rebase -i</code>)</td>
|
<code>git rebase -i</code>)</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -386,10 +386,10 @@ the parent change, even if they touch the same word, and it won't cause any
|
||||||
conflicts.
|
conflicts.
|
||||||
|
|
||||||
Let's try one final command for changing the contents of an exiting commit. That
|
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.
|
checking it out.
|
||||||
```shell script
|
```shell script
|
||||||
$ jj edit -r @--
|
$ jj touchup -r @--
|
||||||
Created 2423c134ea70 ABC
|
Created 2423c134ea70 ABC
|
||||||
Rebased 2 descendant commits
|
Rebased 2 descendant commits
|
||||||
Working copy now at: d31c52e8ca41 (no description set)
|
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
|
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.
|
`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,
|
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.
|
commits may have conflicts.
|
||||||
|
|
||||||
Other commands for rewriting contents of existing commits are `jj restore -i`,
|
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 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).
|
the instructions in the diff).
|
||||||
|
|
|
@ -1132,7 +1132,7 @@ enum Commands {
|
||||||
Squash(SquashArgs),
|
Squash(SquashArgs),
|
||||||
Unsquash(UnsquashArgs),
|
Unsquash(UnsquashArgs),
|
||||||
Restore(RestoreArgs),
|
Restore(RestoreArgs),
|
||||||
Edit(EditArgs),
|
Touchup(TouchupArgs),
|
||||||
Split(SplitArgs),
|
Split(SplitArgs),
|
||||||
Merge(MergeArgs),
|
Merge(MergeArgs),
|
||||||
Rebase(RebaseArgs),
|
Rebase(RebaseArgs),
|
||||||
|
@ -1513,7 +1513,7 @@ struct RestoreArgs {
|
||||||
paths: Vec<String>,
|
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.
|
/// 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
|
/// 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
|
/// unsquash -i` if you instead want to move changes into or out of the parent
|
||||||
/// revision.
|
/// revision.
|
||||||
#[derive(clap::Args, Clone, Debug)]
|
#[derive(clap::Args, Clone, Debug)]
|
||||||
struct EditArgs {
|
struct TouchupArgs {
|
||||||
/// The revision to edit
|
/// The revision to touch up
|
||||||
#[clap(long, short, default_value = "@")]
|
#[clap(long, short, default_value = "@")]
|
||||||
revision: String,
|
revision: String,
|
||||||
}
|
}
|
||||||
|
@ -3731,7 +3731,11 @@ side. If you don't make any changes, then the operation will be aborted.
|
||||||
Ok(())
|
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 mut workspace_command = command.workspace_helper(ui)?;
|
||||||
let commit = workspace_command.resolve_single_rev(ui, &args.revision)?;
|
let commit = workspace_command.resolve_single_rev(ui, &args.revision)?;
|
||||||
workspace_command.check_rewriteable(&commit)?;
|
workspace_command.check_rewriteable(&commit)?;
|
||||||
|
@ -5278,7 +5282,7 @@ where
|
||||||
Commands::Squash(sub_args) => cmd_squash(ui, &command_helper, sub_args),
|
Commands::Squash(sub_args) => cmd_squash(ui, &command_helper, sub_args),
|
||||||
Commands::Unsquash(sub_args) => cmd_unsquash(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::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::Split(sub_args) => cmd_split(ui, &command_helper, sub_args),
|
||||||
Commands::Merge(sub_args) => cmd_merge(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),
|
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
|
// Test that global options are separated out in the help output
|
||||||
let test_env = TestEnvironment::default();
|
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###"
|
insta::assert_snapshot!(stdout.replace(".exe", ""), @r###"
|
||||||
jj-edit
|
jj-touchup
|
||||||
Edit the content changes in a revision
|
Touch up the content changes in a revision
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
jj edit [OPTIONS]
|
jj touchup [OPTIONS]
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-r, --revision <REVISION> The revision to edit [default: @]
|
-r, --revision <REVISION> The revision to touch up [default: @]
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
--at-operation <AT_OPERATION> Operation to load the repo at [default: @] [aliases: at-op]
|
--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",
|
"files-before file1 file2\0files-after JJ-INSTRUCTIONS file2",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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###"
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
Nothing changed.
|
Nothing changed.
|
||||||
"###);
|
"###);
|
||||||
|
@ -49,7 +49,7 @@ fn test_edit() {
|
||||||
|
|
||||||
// Nothing happens if the diff-editor exits with an error
|
// Nothing happens if the diff-editor exits with an error
|
||||||
std::fs::write(&edit_script, "rm file2\0fail").unwrap();
|
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###"
|
insta::assert_snapshot!(stderr, @r###"
|
||||||
Error: Failed to edit diff: The diff tool exited with a non-zero code
|
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
|
// Can edit changes to individual files
|
||||||
std::fs::write(&edit_script, "reset file2").unwrap();
|
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###"
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
Created 8c79910b5033 (no description set)
|
Created 8c79910b5033 (no description set)
|
||||||
Working copy now at: 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
|
// Changes to a commit are propagated to descendants
|
||||||
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
test_env.jj_cmd_success(&repo_path, &["undo"]);
|
||||||
std::fs::write(&edit_script, "write file3\nmodified\n").unwrap();
|
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###"
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
Created 472de2debaff (no description set)
|
Created 472de2debaff (no description set)
|
||||||
Rebased 1 descendant commits
|
Rebased 1 descendant commits
|
||||||
|
@ -126,7 +126,7 @@ fn test_edit_merge() {
|
||||||
"files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1",
|
"files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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###"
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
Created 608f32ad9e19 merge
|
Created 608f32ad9e19 merge
|
||||||
Rebased 1 descendant commits
|
Rebased 1 descendant commits
|
Loading…
Reference in a new issue