t / lib-rebase.shon commit t3404 & t3411: undo copy&paste (29a0334)
   1#!/bin/sh
   2
   3set_fake_editor () {
   4        echo "#!$SHELL_PATH" >fake-editor.sh
   5        cat >> fake-editor.sh <<\EOF
   6case "$1" in
   7*/COMMIT_EDITMSG)
   8        test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
   9        test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
  10        exit
  11        ;;
  12esac
  13test -z "$EXPECT_COUNT" ||
  14        test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
  15        exit
  16test -z "$FAKE_LINES" && exit
  17grep -v '^#' < "$1" > "$1".tmp
  18rm -f "$1"
  19cat "$1".tmp
  20action=pick
  21for line in $FAKE_LINES; do
  22        case $line in
  23        squash|edit)
  24                action="$line";;
  25        *)
  26                echo sed -n "${line}s/^pick/$action/p"
  27                sed -n "${line}p" < "$1".tmp
  28                sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
  29                action=pick;;
  30        esac
  31done
  32EOF
  33
  34        test_set_editor "$(pwd)/fake-editor.sh"
  35        chmod a+x fake-editor.sh
  36}