diff --git a/demos/demo_operation_log.sh b/demos/demo_operation_log.sh index 6b23a88f5..6eb04388a 100755 --- a/demos/demo_operation_log.sh +++ b/demos/demo_operation_log.sh @@ -27,10 +27,10 @@ comment "The repo now looks like this:" run_command "jj log" comment "The most recent portion of the operation log is:" -run_command "jj op log --color=always | head" +run_command_allow_broken_pipe "jj op log | head" comment "Let's undo that rebase operation:" -rebase_op=$(jj --color=never op log | grep '^◉ ' | sed '2q;d' | cut -b4-15) +rebase_op=$(jj --color=never op log --no-graph -T 'id.short(5)' --limit 1 --at-op @--) run_command "jj undo $rebase_op" comment "Note that only the rebase was undone, and the diff --git a/demos/helpers.sh b/demos/helpers.sh index 8a3832aa6..3a35123a9 100644 --- a/demos/helpers.sh +++ b/demos/helpers.sh @@ -14,6 +14,21 @@ run_command() { eval "$@" } +run_command_allow_broken_pipe() { + run_command "$@" || { + EXITCODE="$?" + case $EXITCODE in + 3) + # `jj` exits with error coded 3 on broken pipe, + # which can happen simply because of running + # `jj|head`. + return 0;; + *) + return $EXITCODE;; + esac + } +} + blank() { echo "" }