diff options
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-x | git-submodule.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 9788175979..136e26a2c8 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 @@ -607,7 +613,10 @@ cmd_update() if test $just_cloned -eq 1 then subsha1= - update_module=checkout + case "$update_module" in + merge | rebase | none) + update_module=checkout ;; + esac else subsha1=$(sanitize_submodule_env; cd "$sm_path" && git rev-parse --verify HEAD) || |