Skip to content

Commit

Permalink
Replace branch with bookmark
Browse files Browse the repository at this point in the history
This updates the code blocks in chapters "Branching, merging, and conflicts" and
"Sharing your code with others" following the deprecation of `jj branch` in jj 0.22
(branches got renamed to bookmarks):

https://github.com/martinvonz/jj/blob/main/CHANGELOG.md#0220---2024-10-02

As of jj 0.22, using `remote_branches()` produces a deprecation warning:
remote_branches() is deprecated; use remote_bookmarks() instead

Similarly for `jj branch`:
Warning: `jj branch` is deprecated; use `jj bookmark` instead, which is equivalent
Warning: `jj branch` will be removed in a future version, and this will be a hard error

The following changes were made in the code blocks, based on repeating the walkthrough:

- remote_branches() -> remote_bookmarks()
- jj branch -> jj bookmark
- Include (new?) output of jj bookmark set
- Include (new?) output of jj git fetch
- Update output of jj git push: "force branch" -> move sideways bookmark (and the like)
- Update output of commands which mentioned branches

Note: if the changed command output included change / revision identifiers, these were
hand-adjusted to match those appearing elsewhere in text wherever possible, keeping
things consistent.

With few exceptions this does not update the narrative, so the text still talks about
branches.
  • Loading branch information
mslw authored and steveklabnik committed Oct 18, 2024
1 parent 694462e commit dd8eaca
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/branching-merging-and-conflicts/revsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Additionally, on the `jj` Discord, several folks have settled on this as a
decent revset for larger repositories:

```console
$ jj log -r '@ | ancestors(remote_branches().., 2) | trunk()'
$ jj log -r '@ | ancestors(remote_bookmarks().., 2) | trunk()'
```

This will show the history from the working directory, some detail about remote
Expand Down
9 changes: 5 additions & 4 deletions src/sharing-code/named-branches.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Using named branches in `jj`

Named branches are mostly an interoperability feature in `jj`; other than some
Named branches (or, starting with `jj 0.22`, "bookmarks") are mostly an interoperability feature in `jj`; other than some
sort of "main branch" that indicates where shared history lives, other branches
aren't necessary to get work done. However, if you use a tool like GitHub, which
bases a lot of its functionality around `git` branches, then you'll end up using
more than one named branch.

To create a named branch in `jj`, we can use `jj branch create`:
To create a named branch (bookmark) in `jj`, we can use `jj bookmark create`:

```console
$ jj branch create trunk
$ jj bookmark create trunk
$ jj log --limit 2
@ povouosx [email protected] 2024-03-01 18:12:43.000 -06:00 trunk f68d1623
│ remove goodbye message
Expand Down Expand Up @@ -70,7 +70,8 @@ behavior is a bit surprising for folks coming from `git`, though it fits in with
Regardless, let's update `trunk` to point at `@`:

```console
$ jj branch set trunk
$ jj bookmark set trunk
Moved 1 bookmarks to pzkrzopz fcf669c5 trunk | (empty) (no description set)
$ jj log --limit 2
@ pzkrzopz [email protected] 2024-03-01 22:41:37.000 -06:00 trunk fcf669c5
│ (empty) (no description set)
Expand Down
21 changes: 14 additions & 7 deletions src/sharing-code/remotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ do that like this:
$ jj edit @-
Working copy now at: povouosx f68d1623 remove goodbye message
Parent commit : vvmrvwuz d41c079b refactor printing
$ jj branch set trunk --allow-backwards
$ jj bookmark set trunk --allow-backwards
Moved 1 bookmarks to povouosx f68d1623 | remove goodbye message
$ jj abandon pzkrzopz
Abandoned commit pzkrzopz fcf669c5 (empty) (no description set)
$ jj log --limit 2
Expand All @@ -49,8 +50,11 @@ Anyway, let's push `trunk` up to GitHub:

```console
$ jj git push
Branch changes to push to origin:
Add branch trunk to f68d16233bdc
Changes to push to origin:
Add bookmark trunk to f68d16233bdc
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it.
Working copy now at: znurnwmk f853107d (empty) (no description set)
Parent commit : povouosx f68d1623 | remove goodbye message
```

And now our project is up on GitHub!
Expand All @@ -73,17 +77,20 @@ Let's fetch those changes:

```console
$ jj git fetch
bookmark: trunk@origin [updated] tracked
$ jj log --limit 3
◉ ksrmwuon [email protected] 2024-03-01 23:10:35.000 -06:00 trunk e202b67c
│ Update Cargo.toml
│ @ znurnwmk [email protected] 2024-03-01 18:15:00.000 f853107d
├─╯ (empty) (no description set)
@ povouosx [email protected] 2024-03-01 18:12:43.000 -06:00 f68d1623
│ remove goodbye message
~
```

In this instance, `trunk` did move to the new commit: we asked `jj` to fetch
information from our origin, and so it's adjusted things to match. However, `@`
is still at our current commit.
is still at our current commit (ie. the empty commit created by `jj git push`).

Let's fix that:

Expand Down Expand Up @@ -130,9 +137,9 @@ $ jj describe -m "add a comment to main"
Working copy now at: vmunwxsk 9410db49 add a comment to main
Parent commit : ksrmwuon e202b67c trunk | Update Cargo.toml
$ jj git push -c @
Creating branch push-vmunwxsksqvk for revision @
Branch changes to push to origin:
Add branch push-vmunwxsksqvk to 9410db49f9ba
Creating bookmark push-vmunwxsksqvk for revision vmunwxsksqvk
Changes to push to origin:
Add bookmark push-vmunwxsksqvk to 9410db49f9ba
$ jj log
@ vmunwxsk [email protected] 2024-03-02 08:27:30.000 -06:00 push-vmunwxsksqvk 9410db49
│ add a comment to main
Expand Down
25 changes: 14 additions & 11 deletions src/sharing-code/updating-prs.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ Remember, `jj new` won't move any branches, and so if we push, nothing happens:

```console
$ jj git push
No branches found in the default push revset, `remote_branches(remote=origin)..@`.
Warning: No bookmarks found in the default push revset: remote_bookmarks(remote=origin)..@
Nothing changed.
```

First we have to update the branch to point at our new commit, and then push:

```console
$ jj branch set push-vmunwxsksqvk
$ jj bookmark set push-vmunwxsksqvk
Moved 1 bookmarks to nzsvmmzl ad6b9b14 push-vmunwxsksqvk* | respond to feedback
$ jj git push
Branch changes to push to origin:
Move branch push-vmunwxsksqvk from 9410db49f9ba to ad6b9b149f88
Changes to push to origin:
Move forward bookmark push-vmunwxsksqvk from 9410db49f9ba to ad6b9b149f88
```

![a screenshot of github, showing the new commit below our review](../images/new-pr-commit.png)
Expand Down Expand Up @@ -124,7 +125,8 @@ First, we have to undo what we just did. Here's where we are:
So let's move the branch backwards, then abandon our new change:

```console
$ jj branch set push-vmunwxsksqvk -r @- --allow-backwards
$ jj bookmark set push-vmunwxsksqvk -r @- --allow-backwards
Moved 1 bookmarks to vmunwxsk 9410db49 push-vmunwxsksqvk* | add a comment to main
$ jj edit vmunwxsk
Working copy now at: vmunwxsk 9410db49 push-vmunwxsksqvk* | add a comment to main
Parent commit : ksrmwuon e202b67c trunk | Update Cargo.toml
Expand Down Expand Up @@ -166,8 +168,8 @@ already been "rebased" in a sense. So we can just push:

```console
> jj git push
Branch changes to push to origin:
Force branch push-vmunwxsksqvk from ad6b9b149f88 to 586ea9fd213f
Changes to push to origin:
Move sideways bookmark push-vmunwxsksqvk from ad6b9b149f88 to 586ea9fd213f
```

We can see that reflected on GitHub:
Expand Down Expand Up @@ -233,9 +235,10 @@ Let's update our branch and push:

```console
> jj branch set push-vmunwxsksqvk
Moved 1 bookmarks to msmntwvo 8f7dcd91 push-vmunwxsksqvk* | add a new function
> jj git push
Branch changes to push to origin:
Force branch push-vmunwxsksqvk from 586ea9fd213f to 8f7dcd91ecbf
Changes to push to origin:
Move sideways bookmark push-vmunwxsksqvk from 586ea9fd213f to 8f7dcd91ecbf
```

We now have two changes again. So what happens when we address our review? Well,
Expand Down Expand Up @@ -296,8 +299,8 @@ Working copy now at: msmntwvo 752534be push-vmunwxsksqvk* | add a new function
Parent commit : vmunwxsk f6f7dce9 add a comment to main
Added 0 files, modified 1 files, removed 0 files
$ jj git push
Branch changes to push to origin:
Force branch push-vmunwxsksqvk from 8f7dcd91ecbf to 752534beb39f
Changes to push to origin:
Move sideways bookmark push-vmunwxsksqvk from 8f7dcd91ecbf to 752534beb39f
```

And now we're good! Just that easy. If we didn't want to move `@`, we could have
Expand Down

0 comments on commit dd8eaca

Please sign in to comment.