t / t1012-read-tree-df.shon commit Merge branch 'mg/cvsimport' (0c30ed0)
   1#!/bin/sh
   2
   3test_description='read-tree D/F conflict corner cases'
   4
   5. ./test-lib.sh
   6
   7maketree () {
   8        (
   9                rm -f .git/index .git/index.lock &&
  10                git clean -d -f -f -q -x &&
  11                name="$1" &&
  12                shift &&
  13                for it
  14                do
  15                        path=$(expr "$it" : '\([^:]*\)') &&
  16                        mkdir -p $(dirname "$path") &&
  17                        echo "$it" >"$path" &&
  18                        git update-index --add "$path" || exit
  19                done &&
  20                git tag "$name" $(git write-tree)
  21        )
  22}
  23
  24settree () {
  25        rm -f .git/index .git/index.lock &&
  26        git clean -d -f -f -q -x &&
  27        git read-tree "$1" &&
  28        git checkout-index -f -q -u -a &&
  29        git update-index --refresh
  30}
  31
  32checkindex () {
  33        git ls-files -s |
  34        sed "s|^[0-7][0-7]* $_x40 \([0-3]\)     |\1 |" >current &&
  35        cat >expect &&
  36        test_cmp expect current
  37}
  38
  39test_expect_success setup '
  40        maketree O-000 a/b-2/c/d a/b/c/d a/x &&
  41        maketree A-000 a/b-2/c/d a/b/c/d a/x &&
  42        maketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&
  43        maketree B-000 a/b-2/c/d a/b     a/x &&
  44
  45        maketree O-010 t-0     t/1  t/2 t=3 &&
  46        maketree A-010 t-0 t            t=3 &&
  47        maketree B-010         t/1:     t=3: &&
  48
  49        maketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&
  50        maketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&
  51        :
  52'
  53
  54test_expect_success '3-way (1)' '
  55        settree A-000 &&
  56        git read-tree -m -u O-000 A-000 B-000 &&
  57        checkindex <<-EOF
  58        3 a/b
  59        0 a/b-2/c/d
  60        1 a/b/c/d
  61        2 a/b/c/d
  62        0 a/x
  63        EOF
  64'
  65
  66test_expect_success '3-way (2)' '
  67        settree A-001 &&
  68        git read-tree -m -u O-000 A-001 B-000 &&
  69        checkindex <<-EOF
  70        3 a/b
  71        0 a/b-2/c/d
  72        1 a/b/c/d
  73        2 a/b/c/d
  74        2 a/b/c/e
  75        0 a/x
  76        EOF
  77'
  78
  79test_expect_success '3-way (3)' '
  80        settree A-010 &&
  81        git read-tree -m -u O-010 A-010 B-010 &&
  82        checkindex <<-EOF
  83        2 t
  84        1 t-0
  85        2 t-0
  86        1 t/1
  87        3 t/1
  88        1 t/2
  89        0 t=3
  90        EOF
  91'
  92
  93test_expect_success '2-way (1)' '
  94        settree O-020 &&
  95        git read-tree -m -u O-020 A-020 &&
  96        checkindex <<-EOF
  97        0 ds/dma/ioat/Makefile
  98        0 ds/dma/ioat/registers.h
  99        EOF
 100'
 101
 102test_done