t / t9116-git-svn-log.shon commit Merge branch 'bc/xdiffnl' (bc36540)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Eric Wong
   4#
   5
   6test_description='git svn log tests'
   7. ./lib-git-svn.sh
   8
   9test_expect_success 'setup repository and import' '
  10        mkdir import &&
  11        cd import &&
  12                for i in trunk branches/a branches/b \
  13                         tags/0.1 tags/0.2 tags/0.3; do
  14                        mkdir -p $i && \
  15                        echo hello >> $i/README || exit 1
  16                done && \
  17                svn import -m test . "$svnrepo"
  18                cd .. &&
  19        git svn init "$svnrepo" -T trunk -b branches -t tags &&
  20        git svn fetch &&
  21        git reset --hard trunk &&
  22        echo bye >> README &&
  23        git commit -a -m bye &&
  24        git svn dcommit &&
  25        git reset --hard a &&
  26        echo why >> FEEDME &&
  27        git update-index --add FEEDME &&
  28        git commit -m feedme &&
  29        git svn dcommit &&
  30        git reset --hard trunk &&
  31        echo aye >> README &&
  32        git commit -a -m aye &&
  33        git svn dcommit &&
  34        git reset --hard b &&
  35        echo spy >> README &&
  36        git commit -a -m spy &&
  37        echo try >> README &&
  38        git commit -a -m try &&
  39        git svn dcommit
  40        '
  41
  42test_expect_success 'run log' "
  43        git reset --hard a &&
  44        git svn log -r2 trunk | grep ^r2 &&
  45        git svn log -r4 trunk | grep ^r4 &&
  46        git svn log -r3 | grep ^r3
  47        "
  48
  49test_expect_success 'run log against a from trunk' "
  50        git reset --hard trunk &&
  51        git svn log -r3 a | grep ^r3
  52        "
  53
  54printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
  55
  56test_expect_success 'test ascending revision range' "
  57        git reset --hard trunk &&
  58        git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
  59        "
  60
  61printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
  62
  63test_expect_success 'test descending revision range' "
  64        git reset --hard trunk &&
  65        git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
  66        "
  67
  68printf 'r1 \nr2 \n' > expected-range-r1-r2
  69
  70test_expect_success 'test ascending revision range with unreachable revision' "
  71        git reset --hard trunk &&
  72        git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
  73        "
  74
  75printf 'r2 \nr1 \n' > expected-range-r2-r1
  76
  77test_expect_success 'test descending revision range with unreachable revision' "
  78        git reset --hard trunk &&
  79        git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
  80        "
  81
  82printf 'r2 \n' > expected-range-r2
  83
  84test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
  85        git reset --hard trunk &&
  86        git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
  87        "
  88
  89test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
  90        git reset --hard trunk &&
  91        git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
  92        "
  93
  94printf 'r4 \n' > expected-range-r4
  95
  96test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
  97        git reset --hard trunk &&
  98        git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
  99        "
 100
 101test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
 102        git reset --hard trunk &&
 103        git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 104        "
 105
 106printf -- '------------------------------------------------------------------------\n' > expected-separator
 107
 108test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
 109        git reset --hard trunk &&
 110        git svn log -r 5:6 | test_cmp expected-separator -
 111        "
 112
 113test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
 114        git reset --hard trunk &&
 115        git svn log -r 6:5 | test_cmp expected-separator -
 116        "
 117
 118test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
 119        git reset --hard trunk &&
 120        git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 121        "
 122
 123test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
 124        git reset --hard trunk &&
 125        git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 126        "
 127
 128test_done