4 usage="$0 branch [base-branch] <patchfile"
8 echo >&2 "still in the middle of rebase/am"
23 base_branch=$(git rev-parse --verify "$2") || exit
32 branch_point=$(git merge-base "$base_branch" "$target_branch") || {
33 echo >&2 "failed to compute the branch point"
37 # safety -- never rewind/replace what's merged to next
38 in_branch=$(git rev-list $branch_point..$target_branch) &&
39 not_in_next=$(git rev-list $branch_point..$target_branch ^next) &&
40 test "z$in_branch" = "z$not_in_next" || {
41 echo >&2 "should not be rewinding part of $target_branch that is already in next"
46 git checkout "$branch_point" || {
47 echo >&2 "detaching the head at $branch_point"
52 echo "target_branch=$target_branch"
53 echo "branch_point=$branch_point"
57 echo >&2 "finish the am and say $0 --continue"
63 branch_point=$(sed -ne 's/^branch_point=//p' .rp-state) &&
64 target_branch=$(sed -ne 's/^target_branch=//p' .rp-state) || {
65 echo >&2 "no replace-patch session"
70 git branch -f "$target_branch" HEAD
71 git checkout "$target_branch"
72 git -p show-branch "$target_branch@{1}" "$target_branch"
73 git diff --stat -p "$target_branch@{1}" "$target_branch"