blob: 70361c806e1baf1b26810983374c53eb49ea2f2d [file] [log] [blame]
Junio C Hamano415e96c2005-05-15 14:23:12 -07001#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
Junio C Hamano5be60072007-07-02 22:52:14 -07006test_description='git checkout-index -u test.
Junio C Hamano415e96c2005-05-15 14:23:12 -07007
Junio C Hamano5be60072007-07-02 22:52:14 -07008With -u flag, git checkout-index internally runs the equivalent of
9git update-index --refresh on the checked out entry.'
Junio C Hamano415e96c2005-05-15 14:23:12 -070010
11. ./test-lib.sh
12
13test_expect_success \
14'preparation' '
15echo frotz >path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070016git update-index --add path0 &&
17t=$(git write-tree)'
Junio C Hamano415e96c2005-05-15 14:23:12 -070018
Junio C Hamano41ac4142008-02-01 01:50:53 -080019test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070020'without -u, git checkout-index smudges stat information.' '
Junio C Hamano415e96c2005-05-15 14:23:12 -070021rm -f path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070022git read-tree $t &&
23git checkout-index -f -a &&
Alex Riesen97ad5352008-04-27 13:31:23 +020024test_must_fail git diff-files --exit-code'
Junio C Hamano415e96c2005-05-15 14:23:12 -070025
26test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070027'with -u, git checkout-index picks up stat information from new files.' '
Junio C Hamano415e96c2005-05-15 14:23:12 -070028rm -f path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070029git read-tree $t &&
30git checkout-index -u -f -a &&
Alex Riesen97ad5352008-04-27 13:31:23 +020031git diff-files --exit-code'
Junio C Hamano57fe64a2005-05-19 19:00:36 -070032
33test_done