git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Fredrik Gustafsson <iveqy@iveqy.com>
Cc: jens.lehmann@web.de, hvoigt@hvoigt.net, git@vger.kernel.org
Subject: Re: [PATCH v3] [submodule] Add --depth to submodule update/add
Date: Tue, 02 Jul 2013 12:01:09 -0700	[thread overview]
Message-ID: <7v7gh8947e.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1372729167-23200-1-git-send-email-iveqy@iveqy.com> (Fredrik Gustafsson's message of "Tue, 2 Jul 2013 03:39:27 +0200")

Fredrik Gustafsson <iveqy@iveqy.com> 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 ...

      parent reply	other threads:[~2013-07-02 19:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02  1:39 [PATCH v3] [submodule] Add --depth to submodule update/add Fredrik Gustafsson
2013-07-02 17:10 ` Andreas Schwab
2013-07-02 17:46 ` Jens Lehmann
2013-07-02 18:08   ` [PATCH v4] " Fredrik Gustafsson
2013-07-02 21:14     ` Jens Lehmann
2013-07-02 21:42       ` [PATCH v5] " Fredrik Gustafsson
2013-07-03  7:26         ` Jens Lehmann
2013-07-03  8:13           ` Junio C Hamano
2013-07-03  8:38             ` Fredrik Gustafsson
2013-07-03 17:36           ` Junio C Hamano
2013-07-02 19:01 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v7gh8947e.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=iveqy@iveqy.com \
    --cc=jens.lehmann@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).