2006-08-03 23:41:29 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
test_description='git read-tree --prefix test.
|
2006-08-03 23:41:29 +02:00
|
|
|
'
|
|
|
|
|
2021-10-12 15:56:43 +02:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2006-08-03 23:41:29 +02:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
echo hello >one &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git update-index --add one &&
|
2014-04-28 14:57:34 +02:00
|
|
|
tree=$(git write-tree) &&
|
2006-08-03 23:41:29 +02:00
|
|
|
echo tree is $tree
|
|
|
|
'
|
|
|
|
|
|
|
|
echo 'one
|
|
|
|
two/one' >expect
|
|
|
|
|
|
|
|
test_expect_success 'read-tree --prefix' '
|
2007-07-03 07:52:14 +02:00
|
|
|
git read-tree --prefix=two/ $tree &&
|
|
|
|
git ls-files >actual &&
|
2006-08-03 23:41:29 +02:00
|
|
|
cmp expect actual
|
|
|
|
'
|
|
|
|
|
2022-03-01 21:24:26 +01:00
|
|
|
test_expect_success 'read-tree --prefix with leading slash exits with error' '
|
|
|
|
git rm -rf . &&
|
|
|
|
test_must_fail git read-tree --prefix=/two/ $tree &&
|
|
|
|
git read-tree --prefix=two/ $tree &&
|
|
|
|
|
|
|
|
git rm -rf . &&
|
|
|
|
test_must_fail git read-tree --prefix=/ $tree &&
|
|
|
|
git read-tree --prefix= $tree
|
|
|
|
'
|
|
|
|
|
2006-08-03 23:41:29 +02:00
|
|
|
test_done
|