1#!/bin/sh
   2#
   3# Copyright (c) 2008 Nguyễn Thái Ngọc Duy
   4#
   5test_description='skip-worktree bit test'
   7. ./test-lib.sh
   9test_set_index_version 3
  11cat >expect.full <<EOF
  13H 1
  14H 2
  15H sub/1
  16H sub/2
  17EOF
  18cat >expect.skip <<EOF
  20S 1
  21H 2
  22S sub/1
  23H sub/2
  24EOF
  25test_expect_success 'setup' '
  27        mkdir sub &&
  28        touch ./1 ./2 sub/1 sub/2 &&
  29        git add 1 2 sub/1 sub/2 &&
  30        git ls-files -t | test_cmp expect.full -
  31'
  32test_expect_success 'index is at version 2' '
  34        test "$(test-index-version < .git/index)" = 2
  35'
  36test_expect_success 'update-index --skip-worktree' '
  38        git update-index --skip-worktree 1 sub/1 &&
  39        git ls-files -t | test_cmp expect.skip -
  40'
  41test_expect_success 'index is at version 3 after having some skip-worktree entries' '
  43        test "$(test-index-version < .git/index)" = 3
  44'
  45test_expect_success 'ls-files -t' '
  47        git ls-files -t | test_cmp expect.skip -
  48'
  49test_expect_success 'update-index --no-skip-worktree' '
  51        git update-index --no-skip-worktree 1 sub/1 &&
  52        git ls-files -t | test_cmp expect.full -
  53'
  54test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
  56        test "$(test-index-version < .git/index)" = 2
  57'
  58test_done