#!/bin/sh # # Copyright (c) 2005 Junio C Hamano # global test_description := ''git checkout-index test. This test registers the following filesystem structure in the cache: path0 - a file path1/file1 - a file in a directory And then tries to checkout in a work tree that has the following: path0/file0 - a file in a directory path1 - a file The git checkout-index command should fail when attempting to checkout path0, finding it is occupied by a directory, and path1/file1, finding path1 is occupied by a non-directory. With "-f" flag, it should remove the conflicting paths and succeed. '' source ./test-lib.sh date >path0 mkdir path1 date >path1/file1 test_expect_success \ 'git update-index --add various paths.' \ 'git update-index --add path0 path1/file1' rm -fr path0 path1 mkdir path0 date >path0/file0 date >path1 test_expect_success \ 'git checkout-index without -f should fail on conflicting work tree.' \ 'test_must_fail git checkout-index -a' test_expect_success \ 'git checkout-index with -f should succeed.' \ 'git checkout-index -f -a' test_expect_success \ 'git checkout-index conflicting paths.' \ 'test -f path0 && test -d path1 && test -f path1/file1' test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' ' mkdir -p tar/get && ln -s tar/get there && echo first && git checkout-index -a -f --prefix=there/ && echo second && git checkout-index -a -f --prefix=there/ ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git checkout-index test.\n"> <"\n"> <"This test registers the following filesystem structure in the\n"> <"cache:\n"> <"\n"> <" path0 - a file\n"> <" path1/file1 - a file in a directory\n"> <"\n"> <"And then tries to checkout in a work tree that has the following:\n"> <"\n"> <" path0/file0 - a file in a directory\n"> <" path1 - a file\n"> <"\n"> <"The git checkout-index command should fail when attempting to checkout\n"> <"path0, finding it is occupied by a directory, and path1/file1, finding\n"> <"path1 is occupied by a non-directory. With \"-f\" flag, it should remove\n"> <"the conflicting paths and succeed.\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (SimpleCommand words: [{(date)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(path0)} spids:[41])] ) (C {(mkdir)} {(path1)}) (SimpleCommand words: [{(date)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(path1/file1)} spids:[50])] ) (C {(test_expect_success)} {(SQ <"git update-index --add various paths.">)} {(SQ <"git update-index --add path0 path1/file1">)} ) (C {(rm)} {(-fr)} {(path0)} {(path1)}) (C {(mkdir)} {(path0)}) (SimpleCommand words: [{(date)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(path0/file0)} spids:[83])] ) (SimpleCommand words: [{(date)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(path1)} spids:[88])] ) (C {(test_expect_success)} {(SQ <"git checkout-index without -f should fail on conflicting work tree.">)} {(SQ <"test_must_fail git checkout-index -a">)} ) (C {(test_expect_success)} {(SQ <"git checkout-index with -f should succeed.">)} {(SQ <"git checkout-index -f -a">)} ) (C {(test_expect_success)} {(SQ <"git checkout-index conflicting paths.">)} {(SQ <"test -f path0 && test -d path1 && test -f path1/file1">)} ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"checkout-index -f twice with --prefix">)} { (SQ <"\n"> <"\tmkdir -p tar/get &&\n"> <"\tln -s tar/get there &&\n"> <"\techo first &&\n"> <"\tgit checkout-index -a -f --prefix=there/ &&\n"> <"\techo second &&\n"> <"\tgit checkout-index -a -f --prefix=there/\n"> ) } ) (C {(test_done)}) ] )