t / t2101-update-index-reupdate.shon commit Merge branch 'sp/reflog' into next (dcaad49)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='git-update-index --again test.
   7'
   8
   9. ./test-lib.sh
  10
  11test_expect_success 'update-index --add' \
  12        'echo hello world >file1 &&
  13         echo goodbye people >file2 &&
  14         git-update-index --add file1 file2 &&
  15         git-ls-files -s >current &&
  16         cmp current - <<\EOF
  17100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0       file1
  18100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0       file2
  19EOF'
  20
  21test_expect_success 'update-index --again' \
  22        'rm -f file1 &&
  23        echo hello everybody >file2 &&
  24        if git-update-index --again
  25        then
  26                echo should have refused to remove file1
  27                exit 1
  28        else
  29                echo happy - failed as expected
  30        fi &&
  31         git-ls-files -s >current &&
  32         cmp current - <<\EOF
  33100644 3b18e512dba79e4c8300dd08aeb37f8e728b8dad 0       file1
  34100644 9db8893856a8a02eaa73470054b7c1c5a7c82e47 0       file2
  35EOF'
  36
  37test_expect_success 'update-index --remove --again' \
  38        'git-update-index --remove --again &&
  39         git-ls-files -s >current &&
  40         cmp current - <<\EOF
  41100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0       file2
  42EOF'
  43
  44test_expect_success 'first commit' 'git-commit -m initial'
  45
  46test_expect_success 'update-index again' \
  47        'mkdir -p dir1 &&
  48        echo hello world >dir1/file3 &&
  49        echo goodbye people >file2 &&
  50        git-update-index --add file2 dir1/file3 &&
  51        echo hello everybody >file2
  52        echo happy >dir1/file3 &&
  53        git-update-index --again &&
  54        git-ls-files -s >current &&
  55        cmp current - <<\EOF
  56100644 53ab446c3f4e42ce9bb728a0ccb283a101be4979 0       dir1/file3
  57100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0       file2
  58EOF'
  59
  60test_expect_success 'update-index --update from subdir' \
  61        'echo not so happy >file2 &&
  62        cd dir1 &&
  63        cat ../file2 >file3 &&
  64        git-update-index --again &&
  65        cd .. &&
  66        git-ls-files -s >current &&
  67        cmp current - <<\EOF
  68100644 d7fb3f695f06c759dbf3ab00046e7cc2da22d10f 0       dir1/file3
  69100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0       file2
  70EOF'
  71
  72test_expect_success 'update-index --update with pathspec' \
  73        'echo very happy >file2 &&
  74        cat file2 >dir1/file3 &&
  75        git-update-index --again dir1/ &&
  76        git-ls-files -s >current &&
  77        cmp current - <<\EOF
  78100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0       dir1/file3
  79100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0       file2
  80EOF'
  81
  82test_done