X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=git-submodule.sh;h=89f915cae99b12d134aeb7e72ec460dfe1e8e247;hb=b64ce564ffffea1bd0b595d892fd65d79dda79b3;hp=58713c5467f02dd79efefd4534373757af81713e;hpb=032568d6427d50d5e28c2088db991b117a2be711;p=platform%2Fupstream%2Fgit.git diff --git a/git-submodule.sh b/git-submodule.sh index 58713c5..89f915c 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -10,8 +10,9 @@ USAGE="[--quiet] [--cached] or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] or: $dashless [--quiet] init [--] [...] or: $dashless [--quiet] deinit [-f|--force] (--all| [--] ...) - or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference ] [--recursive] [--] [...] + or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference ] [--recursive] [--[no-]single-branch] [--] [...] or: $dashless [--quiet] set-branch (--default|--branch ) [--] + or: $dashless [--quiet] set-url [--] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...] or: $dashless [--quiet] foreach [--recursive] or: $dashless [--quiet] sync [--recursive] [--] [...] @@ -46,6 +47,7 @@ custom_name= depth= progress= dissociate= +single_branch= die_if_unmatched () { @@ -240,13 +242,15 @@ cmd_add() 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 + if test -z "$force" then - eval_gettextln "The following path is ignored by one of your .gitignore files: -\$sm_path -Use -f if you really want to add it." >&2 - exit 1 + dryerr=$(git add --dry-run --ignore-missing --no-warn-embedded-repo "$sm_path" 2>&1 >/dev/null) + res=$? + if test $res -ne 0 + then + echo >&2 "$dryerr" + exit $res + fi fi if test -n "$custom_name" @@ -525,6 +529,12 @@ cmd_update() --jobs=*) jobs=$1 ;; + --single-branch) + single_branch="--single-branch" + ;; + --no-single-branch) + single_branch="--no-single-branch" + ;; --) shift break @@ -554,6 +564,7 @@ cmd_update() ${dissociate:+"--dissociate"} \ ${depth:+--depth "$depth"} \ ${require_init:+--require-init} \ + $single_branch \ $recommend_shallow \ $jobs \ -- \ @@ -767,6 +778,55 @@ cmd_set_branch() { } # +# Configures a submodule's remote url +# +# $@ = requested path, requested url +# +cmd_set_url() { + while test $# -ne 0 + do + case "$1" in + -q|--quiet) + GIT_QUIET=1 + ;; + --) + shift + break + ;; + -*) + usage + ;; + *) + break + ;; + esac + shift + done + + if test $# -ne 2 + then + usage + fi + + # we can't use `git submodule--helper name` here because internally, it + # hashes the path so a trailing slash could lead to an unintentional no match + name="$(git submodule--helper list "$1" | cut -f2)" + if test -z "$name" + then + exit 1 + fi + + url="$2" + if test -z "$url" + then + exit 1 + fi + + git submodule--helper config submodule."$name".url "$url" + git submodule--helper sync ${GIT_QUIET:+--quiet} "$name" +} + +# # Show commit summary for submodules in index or working tree # # If '--cached' is given, show summary between index and given commit, @@ -1065,7 +1125,7 @@ cmd_absorbgitdirs() while test $# != 0 && test -z "$command" do case "$1" in - add | foreach | init | deinit | update | set-branch | status | summary | sync | absorbgitdirs) + add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs) command=$1 ;; -q|--quiet)