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.
13 TEST_PASSES_SANITIZE_LEAK
=true
16 test_expect_success
'setup' '
17 git config --global protocol.file.allow always
20 test_expect_success
'summary test environment setup' '
22 test_commit -C sm "add file" file file-content file-tag &&
24 git submodule add ./sm my-subm &&
26 git commit -m "add submodule"
29 test_expect_success
'submodule summary output for initialized submodule' '
30 test_commit -C sm "add file2" file2 file2-content file2-tag &&
31 git submodule update --remote &&
33 git commit -m "update submodule" my-subm &&
34 git submodule summary HEAD^ >actual &&
35 rev1=$(git -C sm rev-parse --short HEAD^) &&
36 rev2=$(git -C sm rev-parse --short HEAD) &&
37 cat >expected <<-EOF &&
38 * my-subm ${rev1}...${rev2} (1):
42 test_cmp expected actual
45 test_expect_success
'submodule summary output for deinitialized submodule' '
46 git submodule deinit my-subm &&
47 git submodule summary HEAD^ >actual &&
48 test_must_be_empty actual &&
49 git submodule update --init my-subm &&
50 git submodule summary HEAD^ >actual &&
51 rev1=$(git -C sm rev-parse --short HEAD^) &&
52 rev2=$(git -C sm rev-parse --short HEAD) &&
53 cat >expected <<-EOF &&
54 * my-subm ${rev1}...${rev2} (1):
58 test_cmp expected actual
61 test_expect_success
'submodule summary output for submodules with changed paths' '
62 git mv my-subm subm &&
63 git commit -m "change submodule path" &&
64 rev=$(git -C sm rev-parse --short HEAD^) &&
65 git submodule summary HEAD^^ -- my-subm >actual 2>err &&
66 test_must_be_empty err &&
67 cat >expected <<-EOF &&
68 * my-subm ${rev}...0000000:
71 test_cmp expected actual