Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(merge): Rename `--keep` to `--no-remove`

Maximilian Roos2509d46c845a
diff --git a/fish-functions/git-worktree-merge.fish b/fish-functions/git-worktree-merge.fish
index 44f81c8a8..b9e482fa4 100644
--- a/fish-functions/git-worktree-merge.fish
+++ b/fish-functions/git-worktree-merge.fish
@@ -1,5 +1,5 @@
function git-worktree-merge -d "Finish worktree and merge branch into target branch (default: main)"
- argparse -n git-worktree-merge s/squash k/keep -- $argv
+ argparse -n git-worktree-merge s/squash k/no-remove -- $argv
or return 1
# Get current branch
@@ -79,8 +79,8 @@ function git-worktree-merge -d "Finish worktree and merge branch into target bra
return 1
end
- # Finish worktree unless --keep was specified
- if not set -q _flag_keep
+ # Finish worktree unless --no-remove was specified
+ if not set -q _flag_no_remove
# Always finish the current worktree first (handles cleanup)
if not git-worktree-finish
echo (set_color red)"❌ Failed to finish worktree"(set_color normal) >&2
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 46a938d19..4c4f59c96 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -49,7 +49,7 @@ fn show_untracked_warning(repo: &Repository) -> Result<(), GitError> {
pub fn handle_merge(
target: Option<&str>,
squash_enabled: bool,
- keep: bool,
+ no_remove: bool,
no_verify: bool,
force: bool,
tracked_only: bool,
@@ -132,8 +132,8 @@ pub fn handle_merge(
// Get primary worktree path before cleanup (while we can still run git commands)
let primary_worktree_dir = repo.main_worktree_root()?;
- // Finish worktree unless --keep was specified
- if !keep {
+ // Finish worktree unless --no-remove was specified
+ if !no_remove {
// STEP 1: Check for uncommitted changes before attempting cleanup
// This prevents showing "Cleaning up worktree..." before failing
repo.ensure_clean_working_tree()?;
diff --git a/src/main.rs b/src/main.rs
index 65b446f2e..6ca924b9f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -239,7 +239,7 @@ The merge operation follows a strict order designed for fail-fast execution:
7. Clean up worktree
Removes current worktree and switches primary worktree to target branch if needed.
- Skip removal with --keep.
+ Skip removal with --no-remove.
EXAMPLES
@@ -250,7 +250,7 @@ Merge without squashing:
wt merge --no-squash
Keep worktree after merging:
- wt merge --keep
+ wt merge --no-remove
Skip pre-merge commands:
wt merge --no-verify")]
@@ -263,8 +263,8 @@ Skip pre-merge commands:
squash_enabled: bool,
/// Keep worktree after merging (don't remove)
- #[arg(short, long)]
- keep: bool,
+ #[arg(long = "no-remove")]
+ no_remove: bool,
/// Skip all project hooks (pre-merge-command)
#[arg(long)]
@@ -527,14 +527,14 @@ fn main() {
Commands::Merge {
target,
squash_enabled,
- keep,
+ no_remove,
no_verify,
force,
tracked_only,
} => handle_merge(
target.as_deref(),
squash_enabled,
- keep,
+ no_remove,
no_verify,
force,
tracked_only,
diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rs
index 77b1302e1..d49822083 100644
--- a/tests/integration_tests/directives.rs
+++ b/tests/integration_tests/directives.rs
@@ -109,9 +109,9 @@ fn test_remove_without_internal() {
});
}
-/// Test merge command with internal flag and --keep
+/// Test merge command with internal flag and --no-remove
#[test]
-fn test_merge_internal_keep() {
+fn test_merge_internal_no_remove() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
repo.setup_remote("main");
@@ -155,7 +155,7 @@ fn test_merge_internal_keep() {
cmd.arg("--internal")
.arg("merge")
.arg("main")
- .arg("--keep")
+ .arg("--no-remove")
.current_dir(&feature_wt);
// Note: Using file snapshot instead of inline because multiline inline snapshots
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 23c211801..98de84668 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -70,7 +70,7 @@ fn test_merge_fast_forward() {
}
#[test]
-fn test_merge_with_keep_flag() {
+fn test_merge_with_no_remove_flag() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
repo.setup_remote("main");
@@ -103,11 +103,11 @@ fn test_merge_with_keep_flag() {
.output()
.expect("Failed to commit");
- // Merge with --keep flag (should not finish worktree)
+ // Merge with --no-remove flag (should not finish worktree)
snapshot_merge(
- "merge_with_keep",
+ "merge_with_no_remove",
&repo,
- &["main", "--keep"],
+ &["main", "--no-remove"],
Some(&feature_wt),
);
}
diff --git a/tests/snapshots/integration__integration_tests__directives__merge_internal_keep.snap b/tests/snapshots/integration__integration_tests__directives__merge_internal_no_remove.snap
similarity index 100%
rename from tests/snapshots/integration__integration_tests__directives__merge_internal_keep.snap
rename to tests/snapshots/integration__integration_tests__directives__merge_internal_no_remove.snap
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 8f059d9c8..212b0e853 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -467,7 +467,7 @@ _wt() {
return 0
;;
wt__merge)
- opts="-k -f -v -h --no-squash --keep --no-verify --force --tracked-only --verbose --help [TARGET]"
+ opts="-f -v -h --no-squash --no-remove --no-verify --force --tracked-only --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 94773d54a..09415e413 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -284,7 +284,7 @@ complete -c wt -n "__fish_wt_using_subcommand switch" -s h -l help -d 'Print hel
complete -c wt -n "__fish_wt_using_subcommand remove" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
complete -c wt -n "__fish_wt_using_subcommand remove" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand merge" -l no-squash -d 'Disable squashing commits (by default, commits are squashed into one before merging)'
-complete -c wt -n "__fish_wt_using_subcommand merge" -s k -l keep -d 'Keep worktree after merging (don\'t remove)'
+complete -c wt -n "__fish_wt_using_subcommand merge" -l no-remove -d 'Keep worktree after merging (don\'t remove)'
complete -c wt -n "__fish_wt_using_subcommand merge" -l no-verify -d 'Skip all project hooks (pre-merge-command)'
complete -c wt -n "__fish_wt_using_subcommand merge" -s f -l force -d 'Skip approval prompts for commands'
complete -c wt -n "__fish_wt_using_subcommand merge" -l tracked-only -d 'Only stage tracked files (git add -u) instead of all files (git add -A)'
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 10b5dbc5e..2aca78e64 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -340,8 +340,7 @@ _arguments "${_arguments_options[@]}" : \
(merge)
_arguments "${_arguments_options[@]}" : \
'--no-squash[Disable squashing commits (by default, commits are squashed into one before merging)]' \
-'-k[Keep worktree after merging (don'\''t remove)]' \
-'--keep[Keep worktree after merging (don'\''t remove)]' \
+'--no-remove[Keep worktree after merging (don'\''t remove)]' \
'--no-verify[Skip all project hooks (pre-merge-command)]' \
'-f[Skip approval prompts for commands]' \
'--force[Skip approval prompts for commands]' \
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap b/tests/snapshots/integration__integration_tests__merge__merge_with_no_remove.snap
similarity index 98%
rename from tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap
rename to tests/snapshots/integration__integration_tests__merge__merge_with_no_remove.snap
index 09712a614..ee0448d3b 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_with_keep.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_with_no_remove.snap
@@ -5,7 +5,7 @@ info:
args:
- merge
- main
- - "--keep"
+ - "--no-remove"
env:
CLICOLOR_FORCE: "1"
COLUMNS: "150"