example.sh (1135B)
1 #!/bin/bash 2 3 set -e 4 5 if test -e git-rebasei-example; then 6 echo "Error: git-rebasei-example already exists." 7 exit 1 8 fi 9 10 git init git-rebasei-example 11 pushd git-rebasei-example >/dev/null 12 13 touch a; git add a; git commit -m "Added a." 14 git tag -a -m 'base for the git rebase -i example' rebase-base 15 touch b; git add b; git commit -m "Added b." 16 touch c; git add c; git commit -m "Added c." 17 rm b; git rm b; git commit -m "Removed b." 18 echo c > c; git add c; git commit --fixup="HEAD~1" 19 touch d; git add d; git commit -m "Added d." 20 21 git log --oneline --decorate --graph 22 23 git config git-rebasei-editor.editor cat 24 git rebase -i --autosquash rebase-base 25 26 git log --oneline --decorate --graph 27 28 echo "Comparing with expected git log --name-status…" 29 diff <(git log --pretty=format:%s --name-status) - <<EOF 30 Added d. 31 A d 32 33 Removed b. 34 D b 35 36 Added c. 37 A c 38 39 Added b. 40 A b 41 42 Added a. 43 A a 44 EOF 45 46 echo "Comparing with expected git log --numstat…" 47 diff <(git log --pretty=format:%s --numstat) - <<EOF 48 Added d. 49 0 0 d 50 51 Removed b. 52 0 0 b 53 54 Added c. 55 1 0 c 56 57 Added b. 58 0 0 b 59 60 Added a. 61 0 0 a 62 EOF 63 64 popd > /dev/null 65 66 rm -fr ./git-rebasei-example