blob: fc95cf90485366314dcebb7fe77f18b1d8d4ef1b [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
Ævar Arnfjörð Bjarmasonb7bcdbd2021-10-12 15:56:41 +020011TEST_PASSES_SANITIZE_LEAK=true
Junio C Hamano415e96c2005-05-15 14:23:12 -070012. ./test-lib.sh
13
14test_expect_success \
15'preparation' '
16echo frotz >path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070017git update-index --add path0 &&
18t=$(git write-tree)'
Junio C Hamano415e96c2005-05-15 14:23:12 -070019
Junio C Hamano41ac4142008-02-01 01:50:53 -080020test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070021'without -u, git checkout-index smudges stat information.' '
Junio C Hamano415e96c2005-05-15 14:23:12 -070022rm -f path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070023git read-tree $t &&
24git checkout-index -f -a &&
Alex Riesen97ad5352008-04-27 13:31:23 +020025test_must_fail git diff-files --exit-code'
Junio C Hamano415e96c2005-05-15 14:23:12 -070026
27test_expect_success \
Junio C Hamano5be60072007-07-02 22:52:14 -070028'with -u, git checkout-index picks up stat information from new files.' '
Junio C Hamano415e96c2005-05-15 14:23:12 -070029rm -f path0 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070030git read-tree $t &&
31git checkout-index -u -f -a &&
Alex Riesen97ad5352008-04-27 13:31:23 +020032git diff-files --exit-code'
Junio C Hamano57fe64a2005-05-19 19:00:36 -070033
34test_done