2021-11-07 00:14:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
2023-08-28 22:42:44 +00:00
|
|
|
. "$(dirname "$0")"/helpers.sh
|
2021-11-07 00:14:00 +00:00
|
|
|
|
|
|
|
new_tmp_dir
|
2023-08-29 05:59:58 +00:00
|
|
|
(
|
|
|
|
jj init --config-toml ui.allow-init-native=true
|
|
|
|
echo "first" > file
|
|
|
|
jj branch create first
|
|
|
|
jj commit -m 'first'
|
|
|
|
echo "second" > file
|
|
|
|
jj branch create second
|
|
|
|
jj commit -m 'second'
|
|
|
|
echo "third" > file
|
|
|
|
jj branch create third
|
|
|
|
jj commit -m 'third'
|
|
|
|
) >/dev/null
|
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"
|
2023-09-10 04:17:47 +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
|
|
|
|
2023-09-10 04:17:47 +00:00
|
|
|
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
|