Skip to content

Commit

Permalink
dynamic completion: complete jj git push {-r,-c}
Browse files Browse the repository at this point in the history
I had to guess whether to complete all revisions or just mutable ones. I'm
guessing that `-r` is sometimes used with immutable revisions (as part of a
revset, or for creating special-purpose branches), while `-c` is almost always
used to push a mutable revision. We can change it later if my guess is wrong.
ilyagr committed Jan 22, 2025
1 parent cf69a36 commit 231c968
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cli/src/commands/git/push.rs
Original file line number Diff line number Diff line change
@@ -141,15 +141,32 @@ pub struct GitPushArgs {
#[arg(long)]
allow_private: bool,
/// Push bookmarks pointing to these commits (can be repeated)
#[arg(long, short, value_name = "REVSETS")]
#[arg(
long,
short,
value_name = "REVSETS",
// While `-r` will often be used with mutable revisions, immutable
// revisions can be useful as parts of revsets or to push
// special-purpose branches.
add = ArgValueCandidates::new(complete::all_revisions)
)]
revisions: Vec<RevisionArg>,
/// Push this commit by creating a bookmark based on its change ID (can be
/// repeated)
///
/// The created bookmark will be tracked automatically. Use the
/// `git.push-bookmark-prefix` setting to change the prefix for generated
/// names.
#[arg(long, short, value_name = "REVSETS")]
#[arg(
long,
short,
value_name = "REVSETS",
// I'm guessing that `git push -c` is almost exclusively used with
// recently created mutable revisions, even though it can in theory
// be used with immutable ones as well. We can change it if the guess
// turns out to be wrong.
add = ArgValueCandidates::new(complete::mutable_revisions)
)]
change: Vec<RevisionArg>,
/// Only display what will change on the remote
#[arg(long)]

0 comments on commit 231c968

Please sign in to comment.