#!/bin/bash # Copyright 2026, Alejandro Colomar # SPDX-License-Identifier: GPL-3.0-or-later set -Eeufo pipefail; shopt -s lastpipe; err() { >&2 printf '%s\n' "$(basename "$0"): error: $*"; exit 1; } git rev-parse --git-dir | read -r git_dir; git rev-parse --git-path bisect-rebase | read -r dir; while test $# -ge 1; do case "$1" in --abort) test -d "$dir/" || err 'Not in a bisect-rebase operation?'; set +e; git rebase --abort >/dev/null 2>/dev/null; git bisect reset >/dev/null 2>/dev/null; xargs git checkout <"$dir/head-name"; xargs git reset --hard <"$dir/orig-head"; rm -rf "$dir"; exit 0; ;; --continue) test -d "$dir/" || err 'Not in a bisect-rebase operation?'; if test -d "$git_dir/rebase-merge"; then err 'You must finish the current rebase operation.'; fi; git-bisect-rebase--continue; exit 0; ;; --quit) test -d "$dir/" || err 'Not in a bisect-rebase operation?'; if test -d "$git_dir/rebase-merge"; then err 'You must finish the current rebase operation.'; fi; rm -rf "$dir"; exit 0; ;; *) break; ;; esac; done; mkdir "$dir"; # shellcheck disable=SC2064 # we want expansion now trap "rm -rf '$dir'" EXIT; # shellcheck disable=SC2312 # False positive: cat <<-'__EOF__' | git bisect-rebase [