git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] submodule: no [--merge|--rebase] when newly cloned

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 16, 2011, 19:51 UTC
Message-ID
<7v62sjkbbi.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1297860417-21895-1-git-send-email-olsonse@umich.edu>
"Spencer E. Olson" <olsonse@umich.edu> writes:
Show 5 quoted lines
> 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"?

Show 19 quoted lines
> +# 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.

Show 10 quoted lines
> +	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=
Previous: Spencer E. OlsonNext: Jens Lehmann
Message 2 of 9 in “submodule: no [--merge|--rebase] when newly cloned”
  1. submodule: no [--merge|--rebase] when newly clonedSpencer E. Olson, Feb 16, 2011
  2. Junio C HamanoFeb 16, 2011
  3. Jens LehmannFeb 16, 2011
  4. Junio C HamanoFeb 16, 2011
  5. Spencer E. OlsonFeb 17, 2011
  6. Johannes SixtFeb 17, 2011
  7. Martin von ZweigbergkFeb 18, 2011
  8. Spencer E. OlsonFeb 18, 2011
  9. Martin von ZweigbergkFeb 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.