Skip to content

Commit a97a96f

Browse files
newrengitster
authored andcommitted
Add testcases showing how pathspecs are handled with rev-list --objects
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc5fa2f commit a97a96f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

t/t6000-rev-list-misc.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
3+
test_description='miscellaneous rev-list tests'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
echo content1 >wanted_file &&
9+
echo content2 >unwanted_file &&
10+
git add wanted_file unwanted_file &&
11+
git commit -m one
12+
'
13+
14+
test_expect_success 'rev-list --objects heeds pathspecs' '
15+
git rev-list --objects HEAD -- wanted_file >output &&
16+
grep wanted_file output &&
17+
! grep unwanted_file output
18+
'
19+
20+
test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
21+
mkdir foo &&
22+
>foo/file &&
23+
git add foo/file &&
24+
git commit -m two &&
25+
26+
git rev-list --objects HEAD -- foo >output &&
27+
grep foo/file output &&
28+
29+
git rev-list --objects HEAD -- foo/file >output &&
30+
grep foo/file output &&
31+
! grep unwanted_file output
32+
'
33+
34+
test_expect_success 'rev-list --objects with pathspecs and copied files' '
35+
git checkout --orphan junio-testcase &&
36+
git rm -rf . &&
37+
38+
mkdir two &&
39+
echo frotz >one &&
40+
cp one two/three &&
41+
git add one two/three &&
42+
test_tick &&
43+
git commit -m that &&
44+
45+
ONE=$(git rev-parse HEAD:one)
46+
git rev-list --objects HEAD two >output &&
47+
grep "$ONE two/three" output &&
48+
! grep one output
49+
'
50+
51+
test_done

0 commit comments

Comments
 (0)