diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-05-09 00:37:23 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-05-09 00:37:23 +0900 |
commit | 4ab701b2eec46ab5cbfe8c9732897e5d100184d8 (patch) | |
tree | 9e2001084537775407d1e4376ec9a0f5791d32d6 /git-submodule.sh | |
parent | Merge branch 'dl/warn-tagging-a-tag' (diff) | |
parent | add: error appropriately on repository with no commits (diff) | |
download | tgif-4ab701b2eec46ab5cbfe8c9732897e5d100184d8.tar.xz |
Merge branch 'km/empty-repo-is-still-a-repo'
Running "git add" on a repository created inside the current
repository is an explicit indication that the user wants to add it
as a submodule, but when the HEAD of the inner repository is on an
unborn branch, it cannot be added as a submodule. Worse, the files
in its working tree can be added as if they are a part of the outer
repository, which is not what the user wants. These problems are
being addressed.
* km/empty-repo-is-still-a-repo:
add: error appropriately on repository with no commits
dir: do not traverse repositories with no commits
submodule: refuse to add repository with no commits
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index e3c054bde5..c7f58c5756 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -232,6 +232,13 @@ cmd_add() die "$(eval_gettext "'\$sm_path' already exists in the index and is not a submodule")" fi + if test -d "$sm_path" && + test -z $(git -C "$sm_path" rev-parse --show-cdup 2>/dev/null) + then + git -C "$sm_path" rev-parse --verify -q HEAD >/dev/null || + die "$(eval_gettext "'\$sm_path' does not have a commit checked out")" + fi + if test -z "$force" && ! git add --dry-run --ignore-missing --no-warn-embedded-repo "$sm_path" > /dev/null 2>&1 then |