2021-10-23 04:59:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
2023-08-28 22:42:44 +00:00
|
|
|
. "$(dirname "$0")"/helpers.sh
|
2021-10-23 04:59:07 +00:00
|
|
|
|
|
|
|
new_tmp_dir
|
2023-09-10 04:17:47 +00:00
|
|
|
{
|
|
|
|
jj git clone https://github.com/octocat/Hello-World
|
|
|
|
cd Hello-World
|
2024-08-08 05:00:46 +00:00
|
|
|
jj abandon --ignore-immutable octocat-patch-1@origin
|
2023-09-10 04:17:47 +00:00
|
|
|
jj branch forget octocat-patch-1
|
2024-08-08 05:00:46 +00:00
|
|
|
jj branch track test@origin
|
|
|
|
} > /dev/null 2>&1
|
2021-10-23 04:59:07 +00:00
|
|
|
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "We are in the octocat/Hello-World repo.
|
|
|
|
The \"operation log\" shows the operations
|
|
|
|
so far:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj op log"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
|
|
|
comment "We are going to make some changes to show
|
2023-02-09 00:26:55 +00:00
|
|
|
how the operation log works. Let's add a file, set
|
|
|
|
a description, and rebase onto the \"test\" branch:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "echo stuff > new-file"
|
|
|
|
run_command "jj describe -m stuff"
|
|
|
|
run_command "jj rebase -d test"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
|
|
|
comment "We are now going to make another change off of
|
|
|
|
master:"
|
2024-08-08 05:00:46 +00:00
|
|
|
run_command "jj new master"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj describe -m \"other stuff\""
|
2022-10-21 05:13:09 +00:00
|
|
|
|
|
|
|
comment "The repo now looks like this:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj log"
|
2023-02-15 06:14:19 +00:00
|
|
|
comment "The most recent portion of the operation log
|
|
|
|
is:"
|
2023-09-10 04:17:47 +00:00
|
|
|
run_command_allow_broken_pipe "jj op log --limit 4"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
|
|
|
comment "Let's undo that rebase operation:"
|
2023-08-29 05:59:58 +00:00
|
|
|
rebase_op=$(jj --color=never op log --no-graph -T 'id.short(5)' --limit 1 --at-op @--)
|
2022-05-01 04:55:34 +00:00
|
|
|
run_command "jj undo $rebase_op"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
2023-02-15 06:14:19 +00:00
|
|
|
comment "Note that only the rebase was undone, and the
|
|
|
|
subsequent \"other stuff\" change was not undone:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj log"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
|
|
|
comment "We can also see what the repo looked like
|
|
|
|
after the rebase operation:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj --at-op $rebase_op log"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
2023-02-15 06:14:19 +00:00
|
|
|
comment "Let's say we instead want to go back to the
|
|
|
|
state of the repo right after the rebase:"
|
2022-05-01 04:55:34 +00:00
|
|
|
run_command "jj op restore $rebase_op"
|
2022-10-21 05:13:09 +00:00
|
|
|
|
2023-02-15 06:14:19 +00:00
|
|
|
# TODO: Explain and demo that undo and restore are also recorded? Remove demo
|
|
|
|
# of --at-op?
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "We're now back to before the \"other stuff\"
|
|
|
|
change existed:"
|
2021-10-23 04:59:07 +00:00
|
|
|
run_command "jj log"
|
2023-02-09 00:26:55 +00:00
|
|
|
|
|
|
|
blank
|