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