t / t5520-pull.shon commit color-words: change algorithm to allow for 0-character word boundaries (2e5d200)
   1#!/bin/sh
   2
   3test_description='pulling into void'
   4
   5. ./test-lib.sh
   6
   7D=`pwd`
   8
   9test_expect_success setup '
  10
  11        echo file >file &&
  12        git add file &&
  13        git commit -a -m original
  14
  15'
  16
  17test_expect_success 'pulling into void' '
  18        mkdir cloned &&
  19        cd cloned &&
  20        git init &&
  21        git pull ..
  22'
  23
  24cd "$D"
  25
  26test_expect_success 'checking the results' '
  27        test -f file &&
  28        test -f cloned/file &&
  29        diff file cloned/file
  30'
  31
  32test_expect_success 'pulling into void using master:master' '
  33        mkdir cloned-uho &&
  34        (
  35                cd cloned-uho &&
  36                git init &&
  37                git pull .. master:master
  38        ) &&
  39        test -f file &&
  40        test -f cloned-uho/file &&
  41        test_cmp file cloned-uho/file
  42'
  43
  44test_expect_success 'test . as a remote' '
  45
  46        git branch copy master &&
  47        git config branch.copy.remote . &&
  48        git config branch.copy.merge refs/heads/master &&
  49        echo updated >file &&
  50        git commit -a -m updated &&
  51        git checkout copy &&
  52        test `cat file` = file &&
  53        git pull &&
  54        test `cat file` = updated
  55'
  56
  57test_expect_success 'the default remote . should not break explicit pull' '
  58        git checkout -b second master^ &&
  59        echo modified >file &&
  60        git commit -a -m modified &&
  61        git checkout copy &&
  62        git reset --hard HEAD^ &&
  63        test `cat file` = file &&
  64        git pull . second &&
  65        test `cat file` = modified
  66'
  67
  68test_expect_success '--rebase' '
  69        git branch to-rebase &&
  70        echo modified again > file &&
  71        git commit -m file file &&
  72        git checkout to-rebase &&
  73        echo new > file2 &&
  74        git add file2 &&
  75        git commit -m "new file" &&
  76        git tag before-rebase &&
  77        git pull --rebase . copy &&
  78        test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
  79        test new = $(git show HEAD:file2)
  80'
  81
  82test_expect_success 'branch.to-rebase.rebase' '
  83        git reset --hard before-rebase &&
  84        git config branch.to-rebase.rebase 1 &&
  85        git pull . copy &&
  86        git config branch.to-rebase.rebase 0 &&
  87        test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
  88        test new = $(git show HEAD:file2)
  89'
  90
  91test_expect_success '--rebase with rebased upstream' '
  92
  93        git remote add -f me . &&
  94        git checkout copy &&
  95        git reset --hard HEAD^ &&
  96        echo conflicting modification > file &&
  97        git commit -m conflict file &&
  98        git checkout to-rebase &&
  99        echo file > file2 &&
 100        git commit -m to-rebase file2 &&
 101        git pull --rebase me copy &&
 102        test "conflicting modification" = "$(cat file)" &&
 103        test file = $(cat file2)
 104
 105'
 106
 107test_expect_success 'pull --rebase dies early with dirty working directory' '
 108
 109        git update-ref refs/remotes/me/copy copy^ &&
 110        COPY=$(git rev-parse --verify me/copy) &&
 111        git rebase --onto $COPY copy &&
 112        git config branch.to-rebase.remote me &&
 113        git config branch.to-rebase.merge refs/heads/copy &&
 114        git config branch.to-rebase.rebase true &&
 115        echo dirty >> file &&
 116        git add file &&
 117        test_must_fail git pull &&
 118        test $COPY = $(git rev-parse --verify me/copy) &&
 119        git checkout HEAD -- file &&
 120        git pull &&
 121        test $COPY != $(git rev-parse --verify me/copy)
 122
 123'
 124
 125test_done