|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dashless=$(basename "$0" | sed -e 's/-/ /') |
|
|
USAGE="[--quiet] [--cached] |
|
|
or: $dashless [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>] |
|
|
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...] |
|
|
or: $dashless [--quiet] init [--] [<path>...] |
|
|
or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...) |
|
|
or: $dashless [--quiet] update [--init [--filter=<filter-spec>]] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...] |
|
|
or: $dashless [--quiet] set-branch (--default|--branch <branch>) [--] <path> |
|
|
or: $dashless [--quiet] set-url [--] <path> <newurl> |
|
|
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] absorbgitdirs [--] [<path>...]" |
|
|
OPTIONS_SPEC= |
|
|
SUBDIRECTORY_OK=Yes |
|
|
. git-sh-setup |
|
|
require_work_tree |
|
|
wt_prefix=$(git rev-parse --show-prefix) |
|
|
cd_to_toplevel |
|
|
|
|
|
|
|
|
|
|
|
GIT_PROTOCOL_FROM_USER=0 |
|
|
export GIT_PROTOCOL_FROM_USER |
|
|
|
|
|
command= |
|
|
quiet= |
|
|
branch= |
|
|
force= |
|
|
reference= |
|
|
cached= |
|
|
recursive= |
|
|
init= |
|
|
require_init= |
|
|
files= |
|
|
remote= |
|
|
nofetch= |
|
|
rebase= |
|
|
merge= |
|
|
checkout= |
|
|
custom_name= |
|
|
depth= |
|
|
progress= |
|
|
dissociate= |
|
|
single_branch= |
|
|
jobs= |
|
|
recommend_shallow= |
|
|
filter= |
|
|
|
|
|
isnumber() |
|
|
{ |
|
|
n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_add() |
|
|
{ |
|
|
|
|
|
reference_path= |
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-b | --branch) |
|
|
case "$2" in '') usage ;; esac |
|
|
branch=$2 |
|
|
shift |
|
|
;; |
|
|
-f | --force) |
|
|
force=$1 |
|
|
;; |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--progress) |
|
|
progress=1 |
|
|
;; |
|
|
--reference) |
|
|
case "$2" in '') usage ;; esac |
|
|
reference_path=$2 |
|
|
shift |
|
|
;; |
|
|
--reference=*) |
|
|
reference_path="${1#--reference=}" |
|
|
;; |
|
|
--dissociate) |
|
|
dissociate=1 |
|
|
;; |
|
|
--name) |
|
|
case "$2" in '') usage ;; esac |
|
|
custom_name=$2 |
|
|
shift |
|
|
;; |
|
|
--depth) |
|
|
case "$2" in '') usage ;; esac |
|
|
depth="--depth=$2" |
|
|
shift |
|
|
;; |
|
|
--depth=*) |
|
|
depth=$1 |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
if test -z "$1" |
|
|
then |
|
|
usage |
|
|
fi |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper add ${quiet:+--quiet} ${force:+--force} ${progress:+"--progress"} ${branch:+--branch "$branch"} ${reference_path:+--reference "$reference_path"} ${dissociate:+--dissociate} ${custom_name:+--name "$custom_name"} ${depth:+"$depth"} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_foreach() |
|
|
{ |
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--recursive) |
|
|
recursive=1 |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper foreach ${quiet:+--quiet} ${recursive:+--recursive} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_init() |
|
|
{ |
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper init ${quiet:+--quiet} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_deinit() |
|
|
{ |
|
|
|
|
|
deinit_all= |
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-f|--force) |
|
|
force=$1 |
|
|
;; |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--all) |
|
|
deinit_all=t |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${quiet:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_update() |
|
|
{ |
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--progress) |
|
|
progress=1 |
|
|
;; |
|
|
-i|--init) |
|
|
init=1 |
|
|
;; |
|
|
--require-init) |
|
|
require_init=1 |
|
|
;; |
|
|
--remote) |
|
|
remote=1 |
|
|
;; |
|
|
-N|--no-fetch) |
|
|
nofetch=1 |
|
|
;; |
|
|
-f|--force) |
|
|
force=$1 |
|
|
;; |
|
|
-r|--rebase) |
|
|
rebase=1 |
|
|
;; |
|
|
--reference) |
|
|
case "$2" in '') usage ;; esac |
|
|
reference="--reference=$2" |
|
|
shift |
|
|
;; |
|
|
--reference=*) |
|
|
reference="$1" |
|
|
;; |
|
|
--dissociate) |
|
|
dissociate=1 |
|
|
;; |
|
|
-m|--merge) |
|
|
merge=1 |
|
|
;; |
|
|
--recursive) |
|
|
recursive=1 |
|
|
;; |
|
|
--checkout) |
|
|
checkout=1 |
|
|
;; |
|
|
--recommend-shallow) |
|
|
recommend_shallow="--recommend-shallow" |
|
|
;; |
|
|
--no-recommend-shallow) |
|
|
recommend_shallow="--no-recommend-shallow" |
|
|
;; |
|
|
--depth) |
|
|
case "$2" in '') usage ;; esac |
|
|
depth="--depth=$2" |
|
|
shift |
|
|
;; |
|
|
--depth=*) |
|
|
depth=$1 |
|
|
;; |
|
|
-j|--jobs) |
|
|
case "$2" in '') usage ;; esac |
|
|
jobs="--jobs=$2" |
|
|
shift |
|
|
;; |
|
|
--jobs=*) |
|
|
jobs=$1 |
|
|
;; |
|
|
--single-branch) |
|
|
single_branch="--single-branch" |
|
|
;; |
|
|
--no-single-branch) |
|
|
single_branch="--no-single-branch" |
|
|
;; |
|
|
--filter) |
|
|
case "$2" in '') usage ;; esac |
|
|
filter="--filter=$2" |
|
|
shift |
|
|
;; |
|
|
--filter=*) |
|
|
filter="$1" |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \ |
|
|
${quiet:+--quiet} \ |
|
|
${force:+--force} \ |
|
|
${progress:+"--progress"} \ |
|
|
${remote:+--remote} \ |
|
|
${recursive:+--recursive} \ |
|
|
${init:+--init} \ |
|
|
${nofetch:+--no-fetch} \ |
|
|
${rebase:+--rebase} \ |
|
|
${merge:+--merge} \ |
|
|
${checkout:+--checkout} \ |
|
|
${reference:+"$reference"} \ |
|
|
${dissociate:+"--dissociate"} \ |
|
|
${depth:+"$depth"} \ |
|
|
${require_init:+--require-init} \ |
|
|
${dissociate:+"--dissociate"} \ |
|
|
$single_branch \ |
|
|
$recommend_shallow \ |
|
|
$jobs \ |
|
|
$filter \ |
|
|
-- \ |
|
|
"$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_set_branch() { |
|
|
default= |
|
|
branch= |
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
|
|
|
;; |
|
|
-d|--default) |
|
|
default=1 |
|
|
;; |
|
|
-b|--branch) |
|
|
case "$2" in '') usage ;; esac |
|
|
branch=$2 |
|
|
shift |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-branch ${quiet:+--quiet} ${branch:+--branch "$branch"} ${default:+--default} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_set_url() { |
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper set-url ${quiet:+--quiet} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_summary() { |
|
|
summary_limit=-1 |
|
|
for_status= |
|
|
diff_cmd=diff-index |
|
|
|
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
--cached) |
|
|
cached=1 |
|
|
;; |
|
|
--files) |
|
|
files="$1" |
|
|
;; |
|
|
--for-status) |
|
|
for_status="$1" |
|
|
;; |
|
|
-n|--summary-limit) |
|
|
summary_limit="$2" |
|
|
isnumber "$summary_limit" || usage |
|
|
shift |
|
|
;; |
|
|
--summary-limit=*) |
|
|
summary_limit="${1#--summary-limit=}" |
|
|
isnumber "$summary_limit" || usage |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper summary ${files:+--files} ${cached:+--cached} ${for_status:+--for-status} ${summary_limit:+-n $summary_limit} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_status() |
|
|
{ |
|
|
|
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--cached) |
|
|
cached=1 |
|
|
;; |
|
|
--recursive) |
|
|
recursive=1 |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper status ${quiet:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_sync() |
|
|
{ |
|
|
while test $# -ne 0 |
|
|
do |
|
|
case "$1" in |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
shift |
|
|
;; |
|
|
--recursive) |
|
|
recursive=1 |
|
|
shift |
|
|
;; |
|
|
--) |
|
|
shift |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
done |
|
|
|
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper sync ${quiet:+--quiet} ${recursive:+--recursive} -- "$@" |
|
|
} |
|
|
|
|
|
cmd_absorbgitdirs() |
|
|
{ |
|
|
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper absorbgitdirs "$@" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while test $# != 0 && test -z "$command" |
|
|
do |
|
|
case "$1" in |
|
|
add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs) |
|
|
command=$1 |
|
|
;; |
|
|
-q|--quiet) |
|
|
quiet=1 |
|
|
;; |
|
|
--cached) |
|
|
cached=1 |
|
|
;; |
|
|
--) |
|
|
break |
|
|
;; |
|
|
-*) |
|
|
usage |
|
|
;; |
|
|
*) |
|
|
break |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
|
|
|
if test -z "$command" |
|
|
then |
|
|
if test $# = 0 |
|
|
then |
|
|
command=status |
|
|
else |
|
|
usage |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if test -n "$cached" && test "$command" != status && test "$command" != summary |
|
|
then |
|
|
usage |
|
|
fi |
|
|
|
|
|
"cmd_$(echo $command | sed -e s/-/_/g)" "$@" |
|
|
|