Convert remaining callers of resolve_refdup to object_id
[gitweb.git] / git-submodule.sh
index 554bd1c4943a5f2dd9aa9615dadc962bf6405d7a..136e26a2c8d4ca1e835e2873f3fd994864dc135e 100755 (executable)
@@ -12,7 +12,8 @@ USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re
    or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]
    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
    or: $dashless [--quiet] foreach [--recursive] <command>
-   or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
+   or: $dashless [--quiet] sync [--recursive] [--] [<path>...]
+   or: $dashless [--quiet] absorbgitdirs [--] [<path>...]"
 OPTIONS_SPEC=
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
@@ -203,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
@@ -370,7 +377,7 @@ cmd_init()
                shift
        done
 
-       git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${GIT_QUIET:+--quiet} ${prefix:+--prefix "$prefix"} "$@"
+       git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper init ${GIT_QUIET:+--quiet}  "$@"
 }
 
 #
@@ -606,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) ||