t / t3419-rebase-patch-id.shon commit push: --follow-tags (c2aba15)
   1#!/bin/sh
   2
   3test_description='git rebase - test patch id computation'
   4
   5. ./test-lib.sh
   6
   7test_set_prereq NOT_EXPENSIVE
   8test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
   9test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
  10
  11count()
  12{
  13        i=0
  14        while test $i -lt $1
  15        do
  16                echo "$i"
  17                i=$(($i+1))
  18        done
  19}
  20
  21scramble()
  22{
  23        i=0
  24        while read x
  25        do
  26                if test $i -ne 0
  27                then
  28                        echo "$x"
  29                fi
  30                i=$((($i+1) % 10))
  31        done < "$1" > "$1.new"
  32        mv -f "$1.new" "$1"
  33}
  34
  35run()
  36{
  37        echo \$ "$@"
  38        /usr/bin/time "$@" >/dev/null
  39}
  40
  41test_expect_success 'setup' '
  42        git commit --allow-empty -m initial &&
  43        git tag root
  44'
  45
  46do_tests()
  47{
  48        pr=$1
  49        nlines=$2
  50
  51        test_expect_success $pr "setup: $nlines lines" "
  52                rm -f .gitattributes &&
  53                git checkout -q -f master &&
  54                git reset --hard root &&
  55                count $nlines >file &&
  56                git add file &&
  57                git commit -q -m initial &&
  58                git branch -f other &&
  59
  60                scramble file &&
  61                git add file &&
  62                git commit -q -m 'change big file' &&
  63
  64                git checkout -q other &&
  65                : >newfile &&
  66                git add newfile &&
  67                git commit -q -m 'add small file' &&
  68
  69                git cherry-pick master >/dev/null 2>&1
  70        "
  71
  72        test_debug "
  73                run git diff master^\!
  74        "
  75
  76        test_expect_success $pr 'setup attributes' "
  77                echo 'file binary' >.gitattributes
  78        "
  79
  80        test_debug "
  81                run git format-patch --stdout master &&
  82                run git format-patch --stdout --ignore-if-in-upstream master
  83        "
  84
  85        test_expect_success $pr 'detect upstream patch' "
  86                git checkout -q master &&
  87                scramble file &&
  88                git add file &&
  89                git commit -q -m 'change big file again' &&
  90                git checkout -q other^{} &&
  91                git rebase master &&
  92                test_must_fail test -n \"\$(git rev-list master...HEAD~)\"
  93        "
  94
  95        test_expect_success $pr 'do not drop patch' "
  96                git branch -f squashed master &&
  97                git checkout -q -f squashed &&
  98                git reset -q --soft HEAD~2 &&
  99                git commit -q -m squashed &&
 100                git checkout -q other^{} &&
 101                test_must_fail git rebase squashed &&
 102                rm -rf .git/rebase-apply
 103        "
 104}
 105
 106do_tests NOT_EXPENSIVE 500
 107do_tests EXPENSIVE 50000
 108
 109test_done