Revision 8c8b3bc3f4e859be0af49f91e0d1831a9ae50324 authored by Jeff King on 26 July 2012, 20:32:50 UTC, committed by Junio C Hamano on 26 July 2012, 21:23:35 UTC
In commit f20f387, "git commit" notices and dies much
earlier when we have a bogus commit identity. That commit
did not add a test because we cannot do so reliably (namely,
we can only trigger the behavior on a system where the
automatically generated identity is bogus). However, now
that we have a prerequisite check for this feature, we can
add a test that will at least run on systems that produce
such a bogus identity.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1d7dc26
Raw File
t2000-checkout-cache-clash.sh
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#

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.
'
. ./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
back to top