2006-02-17 08:26:16 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Shawn Pearce
|
|
|
|
#
|
|
|
|
|
2008-09-03 10:59:31 +02:00
|
|
|
test_description='git reset should cull empty subdirs'
|
2021-10-31 00:24:13 +02:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2006-02-17 08:26:16 +01:00
|
|
|
. ./test-lib.sh
|
2021-10-15 11:30:17 +02:00
|
|
|
. "$TEST_DIRECTORY"/lib-diff-data.sh
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'creating initial files' '
|
|
|
|
mkdir path0 &&
|
2021-10-15 11:30:17 +02:00
|
|
|
COPYING_test_data >path0/COPYING &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git add path0/COPYING &&
|
2020-10-20 13:43:15 +02:00
|
|
|
git commit -m add -a
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'creating second files' '
|
|
|
|
mkdir path1 &&
|
2006-02-17 08:26:16 +01:00
|
|
|
mkdir path1/path2 &&
|
2021-10-15 11:30:17 +02:00
|
|
|
COPYING_test_data >path1/path2/COPYING &&
|
|
|
|
COPYING_test_data >path1/COPYING &&
|
|
|
|
COPYING_test_data >COPYING &&
|
|
|
|
COPYING_test_data >path0/COPYING-TOO &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git add path1/path2/COPYING &&
|
|
|
|
git add path1/COPYING &&
|
|
|
|
git add COPYING &&
|
|
|
|
git add path0/COPYING-TOO &&
|
2020-10-20 13:43:15 +02:00
|
|
|
git commit -m change -a
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'resetting tree HEAD^' '
|
|
|
|
git reset --hard HEAD^
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking initial files exist after rewind' '
|
|
|
|
test -d path0 &&
|
|
|
|
test -f path0/COPYING
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking lack of path1/path2/COPYING' '
|
|
|
|
! test -f path1/path2/COPYING
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking lack of path1/COPYING' '
|
|
|
|
! test -f path1/COPYING
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking lack of COPYING' '
|
|
|
|
! test -f COPYING
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking checking lack of path1/COPYING-TOO' '
|
|
|
|
! test -f path0/COPYING-TOO
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking lack of path1/path2' '
|
|
|
|
! test -d path1/path2
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
2020-10-20 13:43:15 +02:00
|
|
|
test_expect_success 'checking lack of path1' '
|
|
|
|
! test -d path1
|
|
|
|
'
|
2006-02-17 08:26:16 +01:00
|
|
|
|
|
|
|
test_done
|