3 # Copyright (C) 2020 Shourya Shukla
6 test_description
='Summary support for submodules, adding them using git submodule add
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.
15 test_expect_success
'setup' '
16 git config --global protocol.file.allow always
19 test_expect_success
'summary test environment setup' '
21 test_commit -C sm "add file" file file-content file-tag &&
23 git submodule add ./sm my-subm &&
25 git commit -m "add submodule"
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 &&
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):
41 test_cmp expected actual
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):
57 test_cmp expected actual
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 &&
65 test_must_be_empty err &&
66 cat >expected <<-EOF &&
67 * my-subm ${rev}...0000000:
70 test_cmp expected actual