t / t3302-notes-index-expensive.shon commit t5541-http-push.sh: add tests for non-fast-forward pushes (1945237)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Johannes E. Schindelin
   4#
   5
   6test_description='Test commit notes index (expensive!)'
   7
   8. ./test-lib.sh
   9
  10test -z "$GIT_NOTES_TIMING_TESTS" && {
  11        say Skipping timing tests
  12        test_done
  13        exit
  14}
  15
  16create_repo () {
  17        number_of_commits=$1
  18        nr=0
  19        test -d .git || {
  20        git init &&
  21        (
  22                while [ $nr -lt $number_of_commits ]; do
  23                        nr=$(($nr+1))
  24                        mark=$(($nr+$nr))
  25                        notemark=$(($mark+1))
  26                        test_tick &&
  27                        cat <<INPUT_END &&
  28commit refs/heads/master
  29mark :$mark
  30committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
  31data <<COMMIT
  32commit #$nr
  33COMMIT
  34
  35M 644 inline file
  36data <<EOF
  37file in commit #$nr
  38EOF
  39
  40blob
  41mark :$notemark
  42data <<EOF
  43note for commit #$nr
  44EOF
  45
  46INPUT_END
  47
  48                        echo "N :$notemark :$mark" >> note_commit
  49                done &&
  50                test_tick &&
  51                cat <<INPUT_END &&
  52commit refs/notes/commits
  53committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
  54data <<COMMIT
  55notes
  56COMMIT
  57
  58INPUT_END
  59
  60                cat note_commit
  61        ) |
  62        git fast-import --quiet &&
  63        git config core.notesRef refs/notes/commits
  64        }
  65}
  66
  67test_notes () {
  68        count=$1 &&
  69        git config core.notesRef refs/notes/commits &&
  70        git log | grep "^    " > output &&
  71        i=$count &&
  72        while [ $i -gt 0 ]; do
  73                echo "    commit #$i" &&
  74                echo "    note for commit #$i" &&
  75                i=$(($i-1));
  76        done > expect &&
  77        test_cmp expect output
  78}
  79
  80cat > time_notes << \EOF
  81        mode=$1
  82        i=1
  83        while [ $i -lt $2 ]; do
  84                case $1 in
  85                no-notes)
  86                        GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
  87                ;;
  88                notes)
  89                        unset GIT_NOTES_REF
  90                ;;
  91                esac
  92                git log >/dev/null
  93                i=$(($i+1))
  94        done
  95EOF
  96
  97time_notes () {
  98        for mode in no-notes notes
  99        do
 100                echo $mode
 101                /usr/bin/time sh ../time_notes $mode $1
 102        done
 103}
 104
 105for count in 10 100 1000 10000; do
 106
 107        mkdir $count
 108        (cd $count;
 109
 110        test_expect_success "setup $count" "create_repo $count"
 111
 112        test_expect_success 'notes work' "test_notes $count"
 113
 114        test_expect_success 'notes timing' "time_notes 100"
 115        )
 116done
 117
 118test_done