]>
Commit | Line | Data |
---|---|---|
ede8a5bb SS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (C) 2020 Shourya Shukla | |
4 | # | |
5 | ||
6 | test_description='Summary support for submodules, adding them using git submodule add | |
7 | ||
8 | This test script tries to verify the sanity of summary subcommand of git submodule | |
9 | while making sure to add submodules using `git submodule add` instead of | |
10 | `git add` as done in t7401. | |
11 | ' | |
12 | ||
13 | . ./test-lib.sh | |
14 | ||
0d3beb71 TB |
15 | test_expect_success 'setup' ' |
16 | git config --global protocol.file.allow always | |
17 | ' | |
18 | ||
ede8a5bb SS |
19 | test_expect_success 'summary test environment setup' ' |
20 | git init sm && | |
21 | test_commit -C sm "add file" file file-content file-tag && | |
22 | ||
23 | git submodule add ./sm my-subm && | |
24 | test_tick && | |
25 | git commit -m "add submodule" | |
26 | ' | |
27 | ||
28 | test_expect_success 'submodule summary output for initialized submodule' ' | |
29 | test_commit -C sm "add file2" file2 file2-content file2-tag && | |
30 | git submodule update --remote && | |
31 | test_tick && | |
32 | git commit -m "update submodule" my-subm && | |
33 | git submodule summary HEAD^ >actual && | |
34 | rev1=$(git -C sm rev-parse --short HEAD^) && | |
35 | rev2=$(git -C sm rev-parse --short HEAD) && | |
36 | cat >expected <<-EOF && | |
37 | * my-subm ${rev1}...${rev2} (1): | |
38 | > add file2 | |
39 | ||
40 | EOF | |
41 | test_cmp expected actual | |
42 | ' | |
43 | ||
44 | test_expect_success 'submodule summary output for deinitialized submodule' ' | |
45 | git submodule deinit my-subm && | |
46 | git submodule summary HEAD^ >actual && | |
47 | test_must_be_empty actual && | |
48 | git submodule update --init my-subm && | |
49 | git submodule summary HEAD^ >actual && | |
50 | rev1=$(git -C sm rev-parse --short HEAD^) && | |
51 | rev2=$(git -C sm rev-parse --short HEAD) && | |
52 | cat >expected <<-EOF && | |
53 | * my-subm ${rev1}...${rev2} (1): | |
54 | > add file2 | |
55 | ||
56 | EOF | |
57 | test_cmp expected actual | |
58 | ' | |
59 | ||
60 | test_expect_success 'submodule summary output for submodules with changed paths' ' | |
61 | git mv my-subm subm && | |
62 | git commit -m "change submodule path" && | |
63 | rev=$(git -C sm rev-parse --short HEAD^) && | |
64 | git submodule summary HEAD^^ -- my-subm >actual 2>err && | |
d79b1455 | 65 | test_must_be_empty err && |
ede8a5bb SS |
66 | cat >expected <<-EOF && |
67 | * my-subm ${rev}...0000000: | |
68 | ||
69 | EOF | |
70 | test_cmp expected actual | |
71 | ' | |
72 | ||
73 | test_done |