diff options
author | Stefan Beller <sbeller@google.com> | 2016-04-28 13:02:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-29 10:05:24 -0700 |
commit | d92028a575dde9c325e23f89c3d2b24f13868c57 (patch) | |
tree | e6ea58d26e09d74c1a78fe54c3e2ef052a1e56c3 /t | |
parent | submodule: port init from shell to C (diff) | |
download | tgif-d92028a575dde9c325e23f89c3d2b24f13868c57.tar.xz |
submodule init: fail gracefully with a missing .gitmodules file
When there is no .gitmodules file availabe to initialize a submodule
from, `submodule_from_path` just returns NULL. We need to check for
that and abort gracefully. When `submodule init` was implemented in shell,
a missing .gitmodules file would result in an error message
No url found for submodule path '%s' in .gitmodules
Replicate that error message for now.
When the .gitmodules file is missing we can probably fail even earlier
for all of the submodules with an improved error message.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7400-submodule-basic.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index f99f674ac7..df6b4da2ba 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -18,6 +18,14 @@ test_expect_success 'setup - initial commit' ' git branch initial ' +test_expect_success 'submodule init aborts on missing .gitmodules file' ' + test_when_finished "git update-index --remove sub" && + git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub && + # missing the .gitmodules file here + test_must_fail git submodule init 2>actual && + test_i18ngrep "No url found for submodule path" actual +' + test_expect_success 'configuration parsing' ' test_when_finished "rm -f .gitmodules" && cat >.gitmodules <<-\EOF && |