t / t5527-fetch-odd-refs.shon commit Merge branch 'maint' (c518059)
   1#!/bin/sh
   2
   3test_description='test fetching of oddly-named refs'
   4. ./test-lib.sh
   5
   6# afterwards we will have:
   7#  HEAD - two
   8#  refs/for/refs/heads/master - one
   9#  refs/heads/master - three
  10test_expect_success 'setup repo with odd suffix ref' '
  11        echo content >file &&
  12        git add . &&
  13        git commit -m one &&
  14        git update-ref refs/for/refs/heads/master HEAD &&
  15        echo content >>file &&
  16        git commit -a -m two &&
  17        echo content >>file &&
  18        git commit -a -m three &&
  19        git checkout HEAD^
  20'
  21
  22test_expect_success 'suffix ref is ignored during fetch' '
  23        git clone --bare file://"$PWD" suffix &&
  24        echo three >expect &&
  25        git --git-dir=suffix log -1 --format=%s refs/heads/master >actual &&
  26        test_cmp expect actual
  27'
  28
  29test_expect_success 'try to create repo with absurdly long refname' '
  30        ref240=$_z40/$_z40/$_z40/$_z40/$_z40/$_z40 &&
  31        ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 &&
  32        git init long &&
  33        (
  34                cd long &&
  35                test_commit long &&
  36                test_commit master
  37        ) &&
  38        if git -C long update-ref refs/heads/$ref1440 long; then
  39                test_set_prereq LONG_REF
  40        else
  41                echo >&2 "long refs not supported"
  42        fi
  43'
  44
  45test_expect_success LONG_REF 'fetch handles extremely long refname' '
  46        git fetch long refs/heads/*:refs/remotes/long/* &&
  47        cat >expect <<-\EOF &&
  48        long
  49        master
  50        EOF
  51        git for-each-ref --format="%(subject)" refs/remotes/long >actual &&
  52        test_cmp expect actual
  53'
  54
  55test_expect_success LONG_REF 'push handles extremely long refname' '
  56        git push long :refs/heads/$ref1440 &&
  57        git -C long for-each-ref --format="%(subject)" refs/heads >actual &&
  58        echo master >expect &&
  59        test_cmp expect actual
  60'
  61
  62test_done