summaryrefslogtreecommitdiff
path: root/test/script/repo.et
blob: d93f700512e5d1e0f05f7dbf17206da8731a935d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
test RepoSubtree:
    node n
    shell on n as git_init:
        mkdir -p work
        git -C work -c init.defaultBranch=master init -q
        git -C work -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit'

        mkdir -p work/first/second
        touch work/first/second/file
        git -C work add first
        git -C work -c user.name=test -c user.email=test commit -q -m 'commit'
        git -C work rev-parse HEAD^{commit}
        git -C work rev-parse HEAD^{tree}
        git -C work rev-parse HEAD:first
        git -C work rev-parse HEAD:first/second

        git clone -q --bare work bare.git

    expect /([0-9a-f]+)/ from git_init capture commit
    expect /([0-9a-f]+)/ from git_init capture root
    expect /([0-9a-f]+)/ from git_init capture sub1
    expect /([0-9a-f]+)/ from git_init capture sub2

    for repo in [ "./work", "./bare.git" ]:
        local:
            spawn as p on n args [ repo, "subtree", commit, "" ]
            expect from p /msg $root/
            expect from p /path (.*)/ capture path
            guard (path == "")

        local:
            spawn as p on n args [ repo, "subtree", commit, "." ]
            expect from p /msg $root/
            expect from p /path (.*)/ capture path
            guard (path == "")

        local:
            spawn as p on n args [ repo, "subtree", commit, "/" ]
            expect from p /msg $root/
            expect from p /path (.*)/ capture path
            guard (path == "")

        local:
            spawn as p on n args [ repo, "subtree", commit, "first" ]
            expect from p /msg $sub1/
            expect from p /path (.*)/ capture path
            guard (path == "first")

        local:
            spawn as p on n args [ repo, "subtree", commit, "./first" ]
            expect from p /msg $sub1/
            expect from p /path (.*)/ capture path
            guard (path == "first")

        local:
            spawn as p on n args [ repo, "subtree", commit, "/first" ]
            expect from p /msg $sub1/
            expect from p /path (.*)/ capture path
            guard (path == "first")

        local:
            spawn as p on n args [ repo, "subtree", commit, "./first/second" ]
            expect from p /msg $sub2/
            expect from p /path (.*)/ capture path
            guard (path == "first/second")

        local:
            spawn as p on n args [ repo, "subtree", commit, "/first/second" ]
            expect from p /msg $sub2/
            expect from p /path (.*)/ capture path
            guard (path == "first/second")

        local:
            spawn as p on n args [ repo, "subtree", "$sub1(first)", "second" ]
            expect from p /msg $sub2/
            expect from p /path (.*)/ capture path
            guard (path == "first/second")

        local:
            spawn as p on n args [ repo, "subtree", "$sub1(first)", "./second" ]
            expect from p /msg $sub2/
            expect from p /path (.*)/ capture path
            guard (path == "first/second")

        local:
            spawn as p on n args [ repo, "subtree", "$sub1(first)", "/second/" ]
            expect from p /msg $sub2/
            expect from p /path (.*)/ capture path
            guard (path == "first/second")