forked from jj-vcs/jj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_operation_log.sh
More file actions
executable file
·59 lines (48 loc) · 1.72 KB
/
demo_operation_log.sh
File metadata and controls
executable file
·59 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -euo pipefail
. "$(dirname "$0")"/helpers.sh
new_tmp_dir
{
jj git clone https://github.com/octocat/Hello-World
cd Hello-World
jj abandon --ignore-immutable octocat-patch-1@origin
jj bookmark forget octocat-patch-1
jj bookmark track test@origin
} > /dev/null 2>&1
comment "We are in the octocat/Hello-World repo.
The \"operation log\" shows the operations
so far:"
run_command "jj op log"
comment "We are going to make some changes to show
how the operation log works. Let's add a file, set
a description, and rebase onto the \"test\" bookmark:"
run_command "echo stuff > new-file"
run_command "jj describe -m stuff"
run_command "jj rebase --onto test"
comment "We are now going to make another change off of
master:"
run_command "jj new master"
run_command "jj describe -m \"other stuff\""
comment "The repo now looks like this:"
run_command "jj log"
comment "The most recent portion of the operation log
is:"
run_command_allow_broken_pipe "jj op log --limit 4"
comment "Let's revert that rebase operation:"
rebase_op=$(jj --color=never op log --no-graph -T 'id.short(5)' --limit 1 --at-op @--)
run_command "jj op revert $rebase_op"
comment "Note that only the rebase was reverted, and the
subsequent \"other stuff\" change was not reverted:"
run_command "jj log"
comment "We can also see what the repo looked like
after the rebase operation:"
run_command "jj --at-op $rebase_op log"
comment "Let's say we instead want to go back to the
state of the repo right after the rebase:"
run_command "jj op restore $rebase_op"
# TODO: Explain and demo that revert and restore are also recorded? Remove demo
# of --at-op?
comment "We're now back to before the \"other stuff\"
change existed:"
run_command "jj log"
blank