git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Spencer E. Olson" <olsonse@umich.edu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] submodule: no [--merge|--rebase] when newly cloned
Date: Wed, 16 Feb 2011 11:51:13 -0800	[thread overview]
Message-ID: <7v62sjkbbi.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1297860417-21895-1-git-send-email-olsonse@umich.edu> (Spencer E. Olson's message of "Wed\, 16 Feb 2011 05\:46\:57 -0700")

"Spencer E. Olson" <olsonse@umich.edu> writes:

> Previously, when a submodule was cloned in the same command execution, --rebase
> or --merge would attempt to run (instead of and) before a checkout, resulting in
> an empty working directory.  This patch ignores --rebase or --merge for a
> particular submodule when that submodule is newly cloned and instead simply
> checks out the appropriate revision.

Sorry, but I cannot parse the problem description, "(instead of and)" part.

Why is it a better thing to do to ignore these options, instead of
detecting the situation and error it out, saying "you are initially
cloning, don't say --rebase"?

> +# Test whether an element of the $3(=IFS) separated list $2 matches $1
> +#
> +str_contains()
> +{
> +	if test -n "$3"
> +	then
> +		local IFS="$3"
> +	fi
> +	for i in $2
> +	do
> +		if test "$i" = "$1"
> +		then
> +			echo "yes"
> +			return
> +		fi
> +	done
> +	echo "no"
> +	return
> +}

We don't allow bash-ism outside POSIX shell in our primary Porcelain set
(the rule is looser for stuff in contrib/), so "local" is out.

Here is how to write the above more concisely, efficiently and portably.

	case "$2;" in
        *";$1;"*)
        	echo yes ;;
        *)
        	echo no ;;
	esac

The trailing ';' takes care of the case where cloned_modules has only one
element, in which case you have ";name" in "$2".  No need for a loop.

> +	cloned_modules=
> ...
>  	while read mode sha1 stage path
>  	do
> @@ -442,6 +464,7 @@ cmd_update()
>  		if ! test -d "$path"/.git -o -f "$path"/.git
>  		then
>  			module_clone "$path" "$url" "$reference"|| exit
> +			cloned_modules="$cloned_modules;$name"
>  			subsha1=

  reply	other threads:[~2011-02-16 19:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 12:46 [PATCH] submodule: no [--merge|--rebase] when newly cloned Spencer E. Olson
2011-02-16 19:51 ` Junio C Hamano [this message]
2011-02-16 20:10   ` Jens Lehmann
2011-02-16 21:41     ` Junio C Hamano
2011-02-17  0:21       ` Spencer E. Olson
2011-02-17  7:10   ` Johannes Sixt
2011-02-18  0:34     ` Martin von Zweigbergk
2011-02-18  0:48       ` Spencer E. Olson
2011-02-18  0:59         ` Martin von Zweigbergk

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=7v62sjkbbi.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=olsonse@umich.edu \
    /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).