t / t5618-alternate-refs.shon commit config: work around bug with includeif:onbranch and early config (85fe0e8)
   1#!/bin/sh
   2
   3test_description='test handling of --alternate-refs traversal'
   4. ./test-lib.sh
   5
   6# Avoid test_commit because we want a specific and known set of refs:
   7#
   8#  base -- one
   9#      \      \
  10#       two -- merged
  11#
  12# where "one" and "two" are on separate refs, and "merged" is available only in
  13# the dependent child repository.
  14test_expect_success 'set up local refs' '
  15        git checkout -b one &&
  16        test_tick &&
  17        git commit --allow-empty -m base &&
  18        test_tick &&
  19        git commit --allow-empty -m one &&
  20        git checkout -b two HEAD^ &&
  21        test_tick &&
  22        git commit --allow-empty -m two
  23'
  24
  25# We'll enter the child repository after it's set up since that's where
  26# all of the subsequent tests will want to run (and it's easy to forget a
  27# "-C child" and get nonsense results).
  28test_expect_success 'set up shared clone' '
  29        git clone -s . child &&
  30        cd child &&
  31        git merge origin/one
  32'
  33
  34test_expect_success 'rev-list --alternate-refs' '
  35        git rev-list --remotes=origin >expect &&
  36        git rev-list --alternate-refs >actual &&
  37        test_cmp expect actual
  38'
  39
  40test_expect_success 'rev-list --not --alternate-refs' '
  41        git rev-parse HEAD >expect &&
  42        git rev-list HEAD --not --alternate-refs >actual &&
  43        test_cmp expect actual
  44'
  45
  46test_expect_success 'limiting with alternateRefsPrefixes' '
  47        test_config core.alternateRefsPrefixes refs/heads/one &&
  48        git rev-list origin/one >expect &&
  49        git rev-list --alternate-refs >actual &&
  50        test_cmp expect actual
  51'
  52
  53test_expect_success 'log --source shows .alternate marker' '
  54        git log --oneline --source --remotes=origin >expect.orig &&
  55        sed "s/origin.* /.alternate /" <expect.orig >expect &&
  56        git log --oneline --source --alternate-refs >actual &&
  57        test_cmp expect actual
  58'
  59
  60test_done