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
|
2024-09-29 21:01:37 +00:00
|
|
|
jj bookmark create first
|
2023-08-29 05:59:58 +00:00
|
|
|
jj commit -m 'first'
|
|
|
|
echo "second" > file
|
2024-09-29 21:01:37 +00:00
|
|
|
jj bookmark create second
|
2023-08-29 05:59:58 +00:00
|
|
|
jj commit -m 'second'
|
|
|
|
echo "third" > file
|
2024-09-29 21:01:37 +00:00
|
|
|
jj bookmark create third
|
2023-08-29 05:59:58 +00:00
|
|
|
jj commit -m 'third'
|
2024-08-08 05:00:46 +00:00
|
|
|
) >/dev/null 2>&1
|
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:"
|
2024-08-08 06:12:40 +00:00
|
|
|
run_command_output_redacted "jj rebase -s third -d first"
|
2021-11-07 00:14:00 +00:00
|
|
|
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:"
|
2024-08-08 05:00:46 +00:00
|
|
|
run_command "jj new second"
|
2021-11-07 00:14:00 +00:00
|
|
|
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"
|
2024-08-08 05:00:46 +00:00
|
|
|
run_command "jj new second third -m merged"
|
2021-11-07 00:14:00 +00:00
|
|
|
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
|