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