t / t9116-git-svn-log.shon commit upload-pack: support hidden refs with protocol v2 (e20b419)
   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        (
  12                cd import &&
  13                for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
  14                do
  15                        mkdir -p $i &&
  16                        echo hello >>$i/README ||
  17                        exit 1
  18                done &&
  19                svn_cmd import -m test . "$svnrepo"
  20        ) &&
  21        git svn init "$svnrepo" -T trunk -b branches -t tags &&
  22        git svn fetch &&
  23        git reset --hard origin/trunk &&
  24        echo bye >> README &&
  25        git commit -a -m bye &&
  26        git svn dcommit &&
  27        git reset --hard origin/a &&
  28        echo why >> FEEDME &&
  29        git update-index --add FEEDME &&
  30        git commit -m feedme &&
  31        git svn dcommit &&
  32        git reset --hard origin/trunk &&
  33        echo aye >> README &&
  34        git commit -a -m aye &&
  35        git svn dcommit &&
  36        git reset --hard origin/b &&
  37        echo spy >> README &&
  38        git commit -a -m spy &&
  39        echo try >> README &&
  40        git commit -a -m try &&
  41        git svn dcommit
  42        '
  43
  44test_expect_success 'run log' "
  45        git reset --hard origin/a &&
  46        git svn log -r2 origin/trunk | grep ^r2 &&
  47        git svn log -r4 origin/trunk | grep ^r4 &&
  48        git svn log -r3 | grep ^r3
  49        "
  50
  51test_expect_success 'run log against a from trunk' "
  52        git reset --hard origin/trunk &&
  53        git svn log -r3 origin/a | grep ^r3
  54        "
  55
  56printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
  57
  58test_expect_success 'test ascending revision range' "
  59        git reset --hard origin/trunk &&
  60        git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
  61        "
  62
  63test_expect_success 'test ascending revision range with --show-commit' "
  64        git reset --hard origin/trunk &&
  65        git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
  66        "
  67
  68test_expect_success 'test ascending revision range with --show-commit (sha1)' "
  69        git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
  70        git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
  71        git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
  72        git reset --hard origin/trunk &&
  73        git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
  74        git rev-parse \$(cat out) >actual &&
  75        test_cmp expected-range-r1-r2-r4-sha1 actual
  76        "
  77
  78printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
  79
  80test_expect_success 'test descending revision range' "
  81        git reset --hard origin/trunk &&
  82        git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
  83        "
  84
  85printf 'r1 \nr2 \n' > expected-range-r1-r2
  86
  87test_expect_success 'test ascending revision range with unreachable revision' "
  88        git reset --hard origin/trunk &&
  89        git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
  90        "
  91
  92printf 'r2 \nr1 \n' > expected-range-r2-r1
  93
  94test_expect_success 'test descending revision range with unreachable revision' "
  95        git reset --hard origin/trunk &&
  96        git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
  97        "
  98
  99printf 'r2 \n' > expected-range-r2
 100
 101test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
 102        git reset --hard origin/trunk &&
 103        git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
 104        "
 105
 106test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
 107        git reset --hard origin/trunk &&
 108        git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
 109        "
 110
 111printf 'r4 \n' > expected-range-r4
 112
 113test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
 114        git reset --hard origin/trunk &&
 115        git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 116        "
 117
 118test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
 119        git reset --hard origin/trunk &&
 120        git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 121        "
 122
 123printf -- '------------------------------------------------------------------------\n' > expected-separator
 124
 125test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
 126        git reset --hard origin/trunk &&
 127        git svn log -r 5:6 | test_cmp expected-separator -
 128        "
 129
 130test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
 131        git reset --hard origin/trunk &&
 132        git svn log -r 6:5 | test_cmp expected-separator -
 133        "
 134
 135test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
 136        git reset --hard origin/trunk &&
 137        git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 138        "
 139
 140test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
 141        git reset --hard origin/trunk &&
 142        git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
 143        "
 144
 145test_done