t / t5511-refspec.shon commit Merge branch 'py/diff-submodule' (2855e70)
   1#!/bin/sh
   2
   3test_description='refspec parsing'
   4
   5. ./test-lib.sh
   6
   7test_refspec () {
   8
   9        kind=$1 refspec=$2 expect=$3
  10        git config remote.frotz.url "." &&
  11        git config --remove-section remote.frotz &&
  12        git config remote.frotz.url "." &&
  13        git config "remote.frotz.$kind" "$refspec" &&
  14        if test "$expect" != invalid
  15        then
  16                title="$kind $refspec"
  17                test='git ls-remote frotz'
  18        else
  19                title="$kind $refspec (invalid)"
  20                test='test_must_fail git ls-remote frotz'
  21        fi
  22        test_expect_success "$title" "$test"
  23}
  24
  25test_refspec push ''                                            invalid
  26test_refspec push ':'                                           invalid
  27
  28test_refspec fetch ''
  29test_refspec fetch ':'
  30
  31test_refspec push 'refs/heads/*:refs/remotes/frotz/*'
  32test_refspec push 'refs/heads/*:refs/remotes/frotz'             invalid
  33test_refspec push 'refs/heads:refs/remotes/frotz/*'             invalid
  34test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy'
  35
  36
  37# These have invalid LHS, but we do not have a formal "valid sha-1
  38# expression syntax checker" so they are not checked with the current
  39# code.  They will be caught downstream anyway, but we may want to
  40# have tighter check later...
  41
  42: test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy'       invalid
  43: test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy'        invalid
  44
  45test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*'
  46test_refspec fetch 'refs/heads/*:refs/remotes/frotz'            invalid
  47test_refspec fetch 'refs/heads:refs/remotes/frotz/*'            invalid
  48test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy'
  49test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy'        invalid
  50test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
  51
  52test_refspec push 'master~1:refs/remotes/frotz/backup'
  53test_refspec fetch 'master~1:refs/remotes/frotz/backup'         invalid
  54test_refspec push 'HEAD~4:refs/remotes/frotz/new'
  55test_refspec fetch 'HEAD~4:refs/remotes/frotz/new'              invalid
  56
  57test_refspec push 'HEAD'
  58test_refspec fetch 'HEAD'
  59test_refspec push 'refs/heads/ nitfol'                          invalid
  60test_refspec fetch 'refs/heads/ nitfol'                         invalid
  61
  62test_refspec push 'HEAD:'                                       invalid
  63test_refspec fetch 'HEAD:'
  64test_refspec push 'refs/heads/ nitfol:'                         invalid
  65test_refspec fetch 'refs/heads/ nitfol:'                        invalid
  66
  67test_refspec push ':refs/remotes/frotz/deleteme'
  68test_refspec fetch ':refs/remotes/frotz/HEAD-to-me'
  69test_refspec push ':refs/remotes/frotz/delete me'               invalid
  70test_refspec fetch ':refs/remotes/frotz/HEAD to me'             invalid
  71
  72test_done