diff --git a/cli/src/commands/git/fetch.rs b/cli/src/commands/git/fetch.rs index 21b21f1d3..f806bb303 100644 --- a/cli/src/commands/git/fetch.rs +++ b/cli/src/commands/git/fetch.rs @@ -37,7 +37,13 @@ pub struct GitFetchArgs { /// /// By default, the specified name matches exactly. Use `glob:` prefix to /// expand `*` as a glob. The other wildcard characters aren't supported. - #[arg(long, short, alias="bookmark", default_value = "glob:*", value_parser = StringPattern::parse)] + #[arg( + long, short, + alias = "bookmark", + default_value = "glob:*", + value_parser = StringPattern::parse, + add = ArgValueCandidates::new(complete::bookmarks), + )] branch: Vec, /// The remote to fetch from (only named remotes are supported, can be /// repeated) diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index 9be3eab78..b2c0c32f7 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -86,7 +86,12 @@ pub struct GitPushArgs { /// By default, the specified name matches exactly. Use `glob:` prefix to /// select bookmarks by wildcard pattern. For details, see /// https://martinvonz.github.io/jj/latest/revsets#string-patterns. - #[arg(long, short, alias="branch", value_parser = StringPattern::parse)] + #[arg( + long, short, + alias = "branch", + value_parser = StringPattern::parse, + add = ArgValueCandidates::new(complete::local_bookmarks), + )] bookmark: Vec, /// Push all bookmarks (including deleted bookmarks) #[arg(long)] diff --git a/cli/tests/test_completion.rs b/cli/tests/test_completion.rs index c9484106c..659876aff 100644 --- a/cli/tests/test_completion.rs +++ b/cli/tests/test_completion.rs @@ -126,6 +126,19 @@ fn test_bookmark_names() { let stdout = test_env.jj_cmd_success(&repo_path, &["--", "jj", "bookmark", "untrack", "a"]); insta::assert_snapshot!(stdout, @"aaa-tracked@origin"); + + let stdout = test_env.jj_cmd_success(&repo_path, &["--", "jj", "git", "push", "-b", "a"]); + insta::assert_snapshot!(stdout, @r" + aaa-local + aaa-tracked + "); + + let stdout = test_env.jj_cmd_success(&repo_path, &["--", "jj", "git", "fetch", "-b", "a"]); + insta::assert_snapshot!(stdout, @r" + aaa-local + aaa-tracked + aaa-untracked + "); } #[test]