test-mergesort: add generate subcommand
[git/debian.git] / t / t7421-submodule-summary-add.sh
blobb070f13714a7ee194e513cffd143ef2b0039afe3
1 #!/bin/sh
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-lib.sh
15 test_expect_success 'summary test environment setup' '
16 git init sm &&
17 test_commit -C sm "add file" file file-content file-tag &&
19 git submodule add ./sm my-subm &&
20 test_tick &&
21 git commit -m "add submodule"
24 test_expect_success 'submodule summary output for initialized submodule' '
25 test_commit -C sm "add file2" file2 file2-content file2-tag &&
26 git submodule update --remote &&
27 test_tick &&
28 git commit -m "update submodule" my-subm &&
29 git submodule summary HEAD^ >actual &&
30 rev1=$(git -C sm rev-parse --short HEAD^) &&
31 rev2=$(git -C sm rev-parse --short HEAD) &&
32 cat >expected <<-EOF &&
33 * my-subm ${rev1}...${rev2} (1):
34 > add file2
36 EOF
37 test_cmp expected actual
40 test_expect_success 'submodule summary output for deinitialized submodule' '
41 git submodule deinit my-subm &&
42 git submodule summary HEAD^ >actual &&
43 test_must_be_empty actual &&
44 git submodule update --init my-subm &&
45 git submodule summary HEAD^ >actual &&
46 rev1=$(git -C sm rev-parse --short HEAD^) &&
47 rev2=$(git -C sm rev-parse --short HEAD) &&
48 cat >expected <<-EOF &&
49 * my-subm ${rev1}...${rev2} (1):
50 > add file2
52 EOF
53 test_cmp expected actual
56 test_expect_success 'submodule summary output for submodules with changed paths' '
57 git mv my-subm subm &&
58 git commit -m "change submodule path" &&
59 rev=$(git -C sm rev-parse --short HEAD^) &&
60 git submodule summary HEAD^^ -- my-subm >actual 2>err &&
61 test_must_be_empty err &&
62 cat >expected <<-EOF &&
63 * my-subm ${rev}...0000000:
65 EOF
66 test_cmp expected actual
69 test_done