1#!/bin/sh 2# 3# Copyright (c) 2005 Junio C Hamano 4# 5 6test_description='git-checkout-cache test. 7 8This test registers the following filesystem structure in the 9cache: 10 11 path0 - a file 12 path1/file1 - a file in a directory 13 14And then tries to checkout in a work tree that has the following: 15 16 path0/file0 - a file in a directory 17 path1 - a file 18 19The git-checkout-cache command should fail when attempting to checkout 20path0, finding it is occupied by a directory, and path1/file1, finding 21path1 is occupied by a non-directory. With "-f" flag, it should remove 22the conflicting paths and succeed. 23' 24. ./test-lib.sh 25 26date>path0 27mkdir path1 28date>path1/file1 29 30test_expect_success \ 31'git-update-cache --add various paths.' \ 32'git-update-cache --add path0 path1/file1' 33 34rm-fr path0 path1 35mkdir path0 36date>path0/file0 37date>path1 38 39test_expect_failure \ 40'git-checkout-cache without -f should fail on conflicting work tree.' \ 41'git-checkout-cache -a' 42 43test_expect_success \ 44'git-checkout-cache with -f should succeed.' \ 45'git-checkout-cache -f -a' 46 47iftest -f path0 &&test -d path1 &&test -f path1/file1 48then 49 test_ok "checkout successful" 50else 51 test_failure "checkout failed" 52fi 53 54test_done 55 56