X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-submodule.sh;h=9ebbab798d21147fc019b6183cad0c462c9dafca;hb=7a876edf5d5224e0755cfabb808b042f300e293d;hp=ad2417d1b0827b80ec884009447adada0ddb8173;hpb=4cd1b99c32d9a345438d098f37e75077d072778f;p=git.git diff --git a/git-submodule.sh b/git-submodule.sh index ad2417d1b..9ebbab798 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -5,7 +5,7 @@ # Copyright (c) 2007 Lars Hjemli dashless=$(basename "$0" | sed -e 's/-/ /') -USAGE="[--quiet] add [-b branch] [--reference ] [--] [] +USAGE="[--quiet] add [-b branch] [-f|--force] [--reference ] [--] [] or: $dashless [--quiet] status [--cached] [--recursive] [--] [...] or: $dashless [--quiet] init [--] [...] or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference ] [--merge] [--recursive] [--] [...] @@ -19,6 +19,7 @@ require_work_tree command= branch= +force= reference= cached= recursive= @@ -133,6 +134,9 @@ cmd_add() branch=$2 shift ;; + -f | --force) + force=$1 + ;; -q|--quiet) GIT_QUIET=1 ;; @@ -201,6 +205,14 @@ cmd_add() git ls-files --error-unmatch "$path" > /dev/null 2>&1 && die "'$path' already exists in the index" + if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 + then + echo >&2 "The following path is ignored by one of your .gitignore files:" && + echo >&2 $path && + echo >&2 "Use -f if you really want to add it." + exit 1 + fi + # perhaps the path exists and is already a git repo, else clone it if test -e "$path" then @@ -234,7 +246,7 @@ cmd_add() ) || die "Unable to checkout submodule '$path'" fi - git add --force "$path" || + git add $force "$path" || die "Failed to add submodule '$path'" git config -f .gitmodules submodule."$path".path "$path" && @@ -827,10 +839,11 @@ cmd_sync() if test -e "$path"/.git then ( + say "Synchronizing submodule url for '$name'" + git config submodule."$name".url "$url" clear_local_git_env cd "$path" remote=$(get_default_remote) - say "Synchronizing submodule url for '$name'" git config remote."$remote".url "$url" ) fi