2021-11-07 00:14:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
. "$(dirname "$0")"/demo_helpers.sh
|
|
|
|
|
|
|
|
new_tmp_dir
|
2022-11-14 05:47:06 +00:00
|
|
|
jj init --config-toml ui.allow-init-native=true
|
2021-11-07 00:14:00 +00:00
|
|
|
echo "first" > file
|
2022-06-09 20:58:34 +00:00
|
|
|
jj branch create first
|
2022-11-05 00:15:35 +00:00
|
|
|
jj commit -m 'first'
|
2021-11-07 00:14:00 +00:00
|
|
|
echo "second" > file
|
2022-06-09 20:58:34 +00:00
|
|
|
jj branch create second
|
2022-11-05 00:15:35 +00:00
|
|
|
jj commit -m 'second'
|
2021-11-07 00:14:00 +00:00
|
|
|
echo "third" > file
|
2022-06-09 20:58:34 +00:00
|
|
|
jj branch create third
|
2022-11-05 00:15:35 +00:00
|
|
|
jj commit -m 'third'
|
2021-11-07 00:14:00 +00:00
|
|
|
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "We are in a repo with three commits, all
|
|
|
|
editing the same line:"
|
2021-11-07 00:14:00 +00:00
|
|
|
run_command "jj log"
|
|
|
|
|
|
|
|
run_command "jj diff -r first"
|
|
|
|
run_command "jj diff -r second"
|
|
|
|
run_command "jj diff -r third"
|
|
|
|
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "Let's reorder the second and third commits:"
|
2021-11-07 00:14:00 +00:00
|
|
|
run_command "jj rebase -s third -d first"
|
|
|
|
run_command "jj rebase -s second -d third"
|
|
|
|
run_command "jj log"
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "The commit labeled \"third\" has a conflict,
|
|
|
|
as expected. What's more interesting is
|
|
|
|
that the top commit has no conflict! That's
|
|
|
|
because it has the changes from all three
|
|
|
|
commits applied to it."
|
2021-11-07 00:14:00 +00:00
|
|
|
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "Let's verify that by looking at its contents:"
|
2021-11-07 00:14:00 +00:00
|
|
|
run_command "jj co second"
|
|
|
|
run_command "cat file"
|
|
|
|
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "Let's now instead make \"second\" and \"third\"
|
|
|
|
sibling and merge them:"
|
2021-11-07 00:14:00 +00:00
|
|
|
run_command "jj rebase -s second -d first"
|
|
|
|
run_command "jj merge second third -m merged"
|
|
|
|
run_command "jj log"
|
2022-10-21 05:13:09 +00:00
|
|
|
comment "Again, because the merge commit has the
|
|
|
|
changes from all three commits, it has no
|
|
|
|
conflict."
|
2023-02-09 00:26:55 +00:00
|
|
|
|
|
|
|
blank
|