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