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