| 1 | # Helper to verify if repo $1 contains a submodule named $2 with gitdir path $3 |
| 2 | |
| 3 | # This does not check filesystem existence. That is done in submodule.c via the |
| 4 | # submodule_name_to_gitdir() API which this helper ends up calling. The gitdirs |
| 5 | # might or might not exist (e.g. when adding a new submodule), so this only |
| 6 | # checks the expected configuration path, which might be overridden by the user. |
| 7 | |
| 8 | verify_submodule_gitdir_path () { |
| 9 | repo="$1" && |
| 10 | name="$2" && |
| 11 | path="$3" && |
| 12 | ( |
| 13 | cd "$repo" && |
| 14 | # Compute expected absolute path |
| 15 | expected="$(git rev-parse --git-common-dir)/$path" && |
| 16 | expected="$(test-tool path-utils real_path "$expected")" && |
| 17 | # Compute actual absolute path |
| 18 | actual="$(git submodule--helper gitdir "$name")" && |
| 19 | actual="$(test-tool path-utils real_path "$actual")" && |
| 20 | echo "$expected" >expect && |
| 21 | echo "$actual" >actual && |
| 22 | test_cmp expect actual |
| 23 | ) |
| 24 | } |