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:


                git clone $quiet ${depth:+"$depth"} -n ...

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to