Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v3] [submodule] Add --depth to submodule update/add

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:58

Fredrik Gustafsson [off-list ref] 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?
quoted hunk
@@ -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 ...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help