|
| 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 | + |
| 15 | +test_expect_success 'summary test environment setup' ' |
| 16 | + git init sm && |
| 17 | + test_commit -C sm "add file" file file-content file-tag && |
| 18 | +
|
| 19 | + git submodule add ./sm my-subm && |
| 20 | + test_tick && |
| 21 | + git commit -m "add submodule" |
| 22 | +' |
| 23 | + |
| 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 |
| 35 | +
|
| 36 | + EOF |
| 37 | + test_cmp expected actual |
| 38 | +' |
| 39 | + |
| 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 |
| 51 | +
|
| 52 | + EOF |
| 53 | + test_cmp expected actual |
| 54 | +' |
| 55 | + |
| 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_i18ngrep "fatal:.*my-subm" err && |
| 62 | + cat >expected <<-EOF && |
| 63 | + * my-subm ${rev}...0000000: |
| 64 | +
|
| 65 | + EOF |
| 66 | + test_cmp expected actual |
| 67 | +' |
| 68 | + |
| 69 | +test_done |
0 commit comments