t / t5510-fetch.shon commit update-index: do not die too early in a read-only repository. (7b802b8)
   1#!/bin/sh
   2# Copyright (c) 2006, Junio C Hamano.
   3
   4test_description='Per branch config variables affects "git fetch".
   5
   6'
   7
   8. ./test-lib.sh
   9
  10D=`pwd`
  11
  12test_expect_success setup '
  13        echo >file original &&
  14        git add file &&
  15        git commit -a -m original'
  16
  17test_expect_success "clone and setup child repos" '
  18        git clone . one &&
  19        cd one &&
  20        echo >file updated by one &&
  21        git commit -a -m "updated by one" &&
  22        cd .. &&
  23        git clone . two &&
  24        cd two &&
  25        git config branch.master.remote one &&
  26        git config remote.one.url ../one/.git/ &&
  27        git config remote.one.fetch refs/heads/master:refs/heads/one &&
  28        cd .. &&
  29        git clone . three &&
  30        cd three &&
  31        git config branch.master.remote two &&
  32        git config branch.master.merge refs/heads/one &&
  33        mkdir -p .git/remotes &&
  34        {
  35                echo "URL: ../two/.git/"
  36                echo "Pull: refs/heads/master:refs/heads/two"
  37                echo "Pull: refs/heads/one:refs/heads/one"
  38        } >.git/remotes/two
  39'
  40
  41test_expect_success "fetch test" '
  42        cd "$D" &&
  43        echo >file updated by origin &&
  44        git commit -a -m "updated by origin" &&
  45        cd two &&
  46        git fetch &&
  47        test -f .git/refs/heads/one &&
  48        mine=`git rev-parse refs/heads/one` &&
  49        his=`cd ../one && git rev-parse refs/heads/master` &&
  50        test "z$mine" = "z$his"
  51'
  52
  53test_expect_success "fetch test for-merge" '
  54        cd "$D" &&
  55        cd three &&
  56        git fetch &&
  57        test -f .git/refs/heads/two &&
  58        test -f .git/refs/heads/one &&
  59        master_in_two=`cd ../two && git rev-parse master` &&
  60        one_in_two=`cd ../two && git rev-parse one` &&
  61        {
  62                echo "$master_in_two    not-for-merge"
  63                echo "$one_in_two       "
  64        } >expected &&
  65        cut -f -2 .git/FETCH_HEAD >actual &&
  66        diff expected actual'
  67
  68test_expect_success 'fetch following tags' '
  69
  70        cd "$D" &&
  71        git tag -a -m 'annotated' anno HEAD &&
  72        git tag light HEAD &&
  73
  74        mkdir four &&
  75        cd four &&
  76        git init &&
  77
  78        git fetch .. :track &&
  79        git show-ref --verify refs/tags/anno &&
  80        git show-ref --verify refs/tags/light
  81
  82'
  83
  84test_done