t / t7111-reset-table.shon commit Merge branch 'pw/add-p-single' (60f8b89)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Christian Couder
   4#
   5
   6test_description='Tests to check that "reset" options follow a known table'
   7
   8. ./test-lib.sh
   9
  10
  11test_expect_success 'creating initial commits' '
  12    test_commit E file1 &&
  13    test_commit D file1 &&
  14    test_commit C file1
  15'
  16
  17while read W1 I1 H1 T opt W2 I2 H2
  18do
  19    test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" '
  20        git reset --hard C &&
  21        if test "$I1" != "$H1"
  22        then
  23            echo "$I1" >file1 &&
  24            git add file1
  25        fi &&
  26        if test "$W1" != "$I1"
  27        then
  28            echo "$W1" >file1
  29        fi &&
  30        if test "$W2" != "XXXXX"
  31        then
  32            git reset --$opt $T &&
  33            test "$(cat file1)" = "$W2" &&
  34            git checkout-index -f -- file1 &&
  35            test "$(cat file1)" = "$I2" &&
  36            git checkout -f HEAD -- file1 &&
  37            test "$(cat file1)" = "$H2"
  38        else
  39            test_must_fail git reset --$opt $T
  40        fi
  41    '
  42done <<\EOF
  43A B C D soft   A B D
  44A B C D mixed  A D D
  45A B C D hard   D D D
  46A B C D merge  XXXXX
  47A B C D keep   XXXXX
  48A B C C soft   A B C
  49A B C C mixed  A C C
  50A B C C hard   C C C
  51A B C C merge  XXXXX
  52A B C C keep   A C C
  53B B C D soft   B B D
  54B B C D mixed  B D D
  55B B C D hard   D D D
  56B B C D merge  D D D
  57B B C D keep   XXXXX
  58B B C C soft   B B C
  59B B C C mixed  B C C
  60B B C C hard   C C C
  61B B C C merge  C C C
  62B B C C keep   B C C
  63B C C D soft   B C D
  64B C C D mixed  B D D
  65B C C D hard   D D D
  66B C C D merge  XXXXX
  67B C C D keep   XXXXX
  68B C C C soft   B C C
  69B C C C mixed  B C C
  70B C C C hard   C C C
  71B C C C merge  B C C
  72B C C C keep   B C C
  73EOF
  74
  75test_expect_success 'setting up branches to test with unmerged entries' '
  76    git reset --hard C &&
  77    git branch branch1 &&
  78    git branch branch2 &&
  79    git checkout branch1 &&
  80    test_commit B1 file1 &&
  81    git checkout branch2 &&
  82    test_commit B file1
  83'
  84
  85while read W1 I1 H1 T opt W2 I2 H2
  86do
  87    test_expect_success "check: $W1 $I1 $H1 $T --$opt $W2 $I2 $H2" '
  88        git reset --hard B &&
  89        test_must_fail git merge branch1 &&
  90        cat file1 >X_file1 &&
  91        if test "$W2" != "XXXXX"
  92        then
  93            git reset --$opt $T &&
  94            if test "$W2" = "X"
  95            then
  96                test_cmp file1 X_file1
  97            else
  98                test "$(cat file1)" = "$W2"
  99            fi &&
 100            git checkout-index -f -- file1 &&
 101            test "$(cat file1)" = "$I2" &&
 102            git checkout -f HEAD -- file1 &&
 103            test "$(cat file1)" = "$H2"
 104        else
 105            test_must_fail git reset --$opt $T
 106        fi
 107    '
 108done <<\EOF
 109X U B C soft   XXXXX
 110X U B C mixed  X C C
 111X U B C hard   C C C
 112X U B C merge  C C C
 113X U B C keep   XXXXX
 114X U B B soft   XXXXX
 115X U B B mixed  X B B
 116X U B B hard   B B B
 117X U B B merge  B B B
 118X U B B keep   XXXXX
 119EOF
 120
 121test_done