aboutsummaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-02-02 13:36:54 -0800
committerJunio C Hamano <gitster@pobox.com>2017-02-02 13:36:54 -0800
commit1e6a89323b57888d5464732ea7a56a5fd385318b (patch)
tree6cbc07e63f23e720ab3da3068c997d2ec9d169cd /git-submodule.sh
parent8f60064c1f538f06e1c579cbd9840b86b10bcd3d (diff)
parent619acfc78c526bc9df17b7704e60d0512ab7a84c (diff)
downloadgit-1e6a89323b57888d5464732ea7a56a5fd385318b.tar.gz
git-1e6a89323b57888d5464732ea7a56a5fd385318b.tar.xz
Merge branch 'sb/submodule-add-force'
"git submodule add" used to be confused and refused to add a locally created repository; users can now use "--force" option to add them. * sb/submodule-add-force: submodule add: extend force flag to add existing repos
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 978817597..123ac104c 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -204,8 +204,14 @@ cmd_add()
tstart
s|/*$||
')
- git ls-files --error-unmatch "$sm_path" > /dev/null 2>&1 &&
- die "$(eval_gettext "'\$sm_path' already exists in the index")"
+ if test -z "$force"
+ then
+ git ls-files --error-unmatch "$sm_path" > /dev/null 2>&1 &&
+ die "$(eval_gettext "'\$sm_path' already exists in the index")"
+ else
+ git ls-files -s "$sm_path" | sane_grep -v "^160000" > /dev/null 2>&1 &&
+ die "$(eval_gettext "'\$sm_path' already exists in the index and is not a submodule")"
+ fi
if test -z "$force" && ! git add --dry-run --ignore-missing "$sm_path" > /dev/null 2>&1
then