Skip to content

Commit cd8e8e2

Browse files
committed
cli: git push: show hint when the only changed bookmarks are deleted ones
1 parent fa00775 commit cd8e8e2

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3838

3939
* New `signed` revset function to filter for cryptographically signed commits.
4040

41+
* `jj git push` now shows a hint to use `--deleted` if the only changed bookmarks
42+
are deleted ones.
43+
4144
### Fixed bugs
4245

4346
* Fixed crash on change-delete conflict resolution.

cli/src/commands/git/push.rs

+19
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,25 @@ pub fn cmd_git_push(
395395
);
396396
}
397397
if bookmark_updates.is_empty() {
398+
let deleted_bookmarks = tx
399+
.repo()
400+
.view()
401+
.local_remote_bookmarks(remote)
402+
.filter(|(_, targets)| {
403+
!targets.local_target.is_present()
404+
&& matches!(classify_bookmark_push_action(*targets),
405+
BookmarkPushAction::Update(update) if update.new_target.is_none())
406+
})
407+
.count();
408+
409+
if deleted_bookmarks > 0 {
410+
writeln!(
411+
ui.hint_default(),
412+
"You can push {deleted_bookmarks} deleted bookmark{s} with `--deleted`",
413+
s = if deleted_bookmarks > 1 { "s" } else { "" }
414+
)?;
415+
}
416+
398417
writeln!(ui.status(), "Nothing changed.")?;
399418
return Ok(());
400419
}

cli/tests/test_git_push.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,14 @@ fn test_git_push_deleted(subprocess: bool) {
19611961
work_dir
19621962
.run_jj(["bookmark", "delete", "bookmark1"])
19631963
.success();
1964+
let output = work_dir.run_jj(["git", "push"]);
1965+
insta::assert_snapshot!(output, @r"
1966+
------- stderr -------
1967+
Warning: No bookmarks found in the default push revset: remote_bookmarks(remote=origin)..@
1968+
Hint: You can push 1 deleted bookmark with `--deleted`
1969+
Nothing changed.
1970+
[EOF]
1971+
");
19641972
let output = work_dir.run_jj(["git", "push", "--deleted"]);
19651973
insta::allow_duplicates! {
19661974
insta::assert_snapshot!(output, @r"

0 commit comments

Comments
 (0)