Skip to content

Commit 670c57d

Browse files
committed
cli git push: always allow pushing explicitly named bookmarks
By explicitly naming the bookmark to push, users already express their intent to push that particular bookmark. Requiring them to express that intent a second time by manually marking the bookmark as tracked is therefore unnecessary.
1 parent c49a60e commit 670c57d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2424
filesystem's behavior, but this can be overridden manually by setting
2525
`working-copy.exec-bit-change = "respect" | "ignore"`.
2626

27+
* `jj git push --bookmark <name>` will now automatically track the bookmark if
28+
it wasn't already.
29+
2730
### Fixed bugs
2831

2932
* Broken symlink on Windows. [#6934](https://github.com/jj-vcs/jj/issues/6934).

cli/src/commands/git/push.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ pub fn cmd_git_push(
349349
continue;
350350
}
351351
let remote_symbol = name.to_remote_symbol(remote);
352+
let allow_new = true; // named explicitly, allow push without manually tracking
352353
let allow_delete = true; // named explicitly, allow delete without --delete
353354
match classify_bookmark_update(remote_symbol, targets, allow_new, allow_delete) {
354355
Ok(Some(update)) => bookmark_updates.push((name.to_owned(), update)),

cli/tests/test_git_push.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ fn test_git_push_mixed() {
13691369
.success();
13701370
work_dir.write_file("file", "modified again");
13711371

1372-
// --allow-new is not implied for --bookmark=.. and -r=..
1372+
// --allow-new is not implied for -r=..
13731373
let output = work_dir.run_jj([
13741374
"git",
13751375
"push",
@@ -1380,10 +1380,14 @@ fn test_git_push_mixed() {
13801380
insta::assert_snapshot!(output, @r"
13811381
------- stderr -------
13821382
Creating bookmark push-yqosqzytrlsw for revision yqosqzytrlsw
1383-
Error: Refusing to create new remote bookmark bookmark-1@origin
1384-
Hint: Run `jj bookmark track bookmark-1@origin` and try again.
1383+
Warning: Refusing to create new remote bookmark bookmark-2a@origin
1384+
Hint: Run `jj bookmark track bookmark-2a@origin` and try again.
1385+
Warning: Refusing to create new remote bookmark bookmark-2b@origin
1386+
Hint: Run `jj bookmark track bookmark-2b@origin` and try again.
1387+
Changes to push to origin:
1388+
Add bookmark push-yqosqzytrlsw to 0f8164cd580b
1389+
Add bookmark bookmark-1 to e76139e55e1e
13851390
[EOF]
1386-
[exit status: 1]
13871391
");
13881392

13891393
let output = work_dir.run_jj([
@@ -1397,10 +1401,9 @@ fn test_git_push_mixed() {
13971401
insta::assert_snapshot!(output, @r"
13981402
------- stderr -------
13991403
Warning: --allow-new is deprecated, track bookmarks manually or configure remotes.<name>.auto-track-bookmarks instead.
1400-
Creating bookmark push-yqosqzytrlsw for revision yqosqzytrlsw
1404+
Bookmark push-yqosqzytrlsw@origin already matches push-yqosqzytrlsw
1405+
Bookmark bookmark-1@origin already matches bookmark-1
14011406
Changes to push to origin:
1402-
Add bookmark push-yqosqzytrlsw to 0f8164cd580b
1403-
Add bookmark bookmark-1 to e76139e55e1e
14041407
Add bookmark bookmark-2a to 57d822f901bb
14051408
Add bookmark bookmark-2b to 57d822f901bb
14061409
[EOF]

0 commit comments

Comments
 (0)