From: Junio C Hamano Date: Tue, 02 Jul 2013 19:01:09 GMT Subject: Re: [PATCH v3] [submodule] Add --depth to submodule update/add Message-ID: <7v7gh8947e.fsf@alter.siamese.dyndns.org> In-Reply-To: <1372729167-23200-1-git-send-email-iveqy@iveqy.com> Fredrik Gustafsson writes: > git clone dies with the error "too many arguments". This was solved with changing > depth=$5 > to > depth="$5" > > which I don't understand since variable assignment doesn't expand $5 and therefore > "" should not be needed, AFAIK. Any comments on this? A red herring? > @@ -211,6 +212,7 @@ module_clone() > name=$2 > url=$3 > reference="$4" > + depth="$5" If the caller gave you only 4 arguments, depth will become an empty string with or without dq around $5 here. And > - git clone $quiet -n ${reference:+"$reference"} \ > + git clone $quiet $depth -n ${reference:+"$reference"} \ > --separate-git-dir "$gitdir" "$url" "$sm_path" ... you use $depth without dq around it, so when $depth is empty string, "git clone" will not see it at all (not even an empty string as one of its arguments). Which is probably fine, as long as the caller makes sure it will not call this function as module_clone 1 2 3 4 "depth argument as multi-word" which will be split at $IFS. If you know $depth must be passed as a single argument (or no argument when the caller did not give you any) to the underlying "git clone", you can write it like so: ... depth=$5 ... git clone $quiet ${depth:+"$depth"} -n ...