From 798b4bc897178c4ae7c29593eada68e60f0c7d00 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 6 Nov 2021 17:14:00 -0700 Subject: [PATCH] demos: add demo showing how conflicting commits can be rebased etc --- README.md | 5 +++ demos/demo_juggle_conflicts.sh | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 demos/demo_juggle_conflicts.sh diff --git a/README.md b/README.md index 39561f8e1..85b47f819 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,14 @@ Features: This design also lets Jujutsu rebase merge commits correctly (unlike both Git and Mercurial). + Basic conflict resolution: + Juggling conflicts: + + + * **Automatic rebase** diff --git a/demos/demo_juggle_conflicts.sh b/demos/demo_juggle_conflicts.sh new file mode 100755 index 000000000..f5450bdef --- /dev/null +++ b/demos/demo_juggle_conflicts.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -euo pipefail +. "$(dirname "$0")"/demo_helpers.sh +parse_args "$@" + +new_tmp_dir +jj init +echo "first" > file +jj branch first +jj close -m 'first' +echo "second" > file +jj branch second +jj close -m 'second' +echo "third" > file +jj branch third +jj close -m 'third' + +run_demo 'Juggling conflicts' ' +run_command "# We are in a repo with three commits, all" +run_command "# editing the same line:" +run_command "jj log" +pause 3 + +run_command "jj diff -r first" +pause 1 +run_command "jj diff -r second" +pause 1 +run_command "jj diff -r third" +run_command "" +pause 2 + +run_command "# Let'\''s reorder the second and third commits:" +run_command "jj rebase -s third -d first" +run_command "jj rebase -s second -d third" +run_command "jj log" +pause 3 +run_command "# The commit labeled \"third\" has a conflict," +run_command "# as expected. What'\''s more interesting is" +run_command "# that the top commit has no conflict! That'\''s" +run_command "# because it has the changes from all three" +run_command "# commits applied to it." +run_command "" +pause 5 + +run_command "# Let'\''s verify that by looking at its contents:" +run_command "jj co second" +run_command "cat file" +run_command "" +pause 3 + +run_command "# Let'\''s now instead make \"second\" and \"third\"" +run_command "# sibling and merge them:" +run_command "jj rebase -s second -d first" +run_command "jj merge second third -m merged" +run_command "jj log" +pause 3 +run_command "# Again, because the merge commit has the" +run_command "# changes from all three commits, it has no" +run_command "# conflict." +'