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

Re: [PATCH 2/2] git-submodule: add "sync" command

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2008, 23:13 UTC
Message-ID
<7vhc9c63ua.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<e1d3f1871f869a0161fb3f0d84777de9e0125023.1219390139.git.davvid@gmail.com>
David Aguilar <davvid@gmail.com> writes:
> When a submodule's URL changes upstream, existing submodules
> will be out of sync since their remote.origin.url will still
> be set to the old value.
Ok.
Show 41 quoted lines
> +#
> +# Sync git urls for submodules
> +# This makes the value for remote.origin.url match the value
> +# specified in .gitmodules.
> +#
> +cmd_sync()
> +{
> +	while test $# -ne 0
> +	do
> +		case "$1" in
> +		-q|--quiet)
> +			quiet=1
> +			;;
> +		-*)
> +			usage
> +			;;
> +		--)
> +			shift
> +			break
> +			;;
> +		*)
> +			break
> +			;;
> +		esac
> +		shift
> +	done
> +
> +	cd_to_toplevel
> +
> +	module_list "$@" |
> +	while read mode sha1 stage path
> +	do
> +		! test -f "$path"/.git/config &&
> +		echo "Warn: submodule at path '$path' does not exist."
> +		test -f "$path"/.git/config || continue
> +		name=$(module_name "$path")
> +		url=$(git config -f .gitmodules --get submodule."$name".url)
> +		say "Synchronizing submodule url for '$name'"
> +		git config -f "$path"/.git/config remote.origin.url "$url"
> +	done
> +}
Hmm.  I do not quite like this.

We allow using a gitfile for submodule $GIT_DIR; checking for file existence of "$path/.git/config" does not work for such a configuration.

Neither does 'git config -f "$path/.git/config"' work. I think it should be more like:

    ( unset GIT_DIR; cd "$path" && git config remote.origin.url "$url" )

It is a norm not to have any interest in a submodule that appears in the index of a superproject. You shouldn't get as many warnings as you have submodules in such a repository. You should just skip them (which you already do, but see above), or at least honor "$quiet".

I also think the warning should be sent to the standard error stream.
Previous: David AguilarNext: Junio C Hamano
Message 3 of 8 in “git-submodule: replace duplicated code with a module_list function”
  1. 1/2 git-submodule: replace duplicated code with a module_list functionDavid Aguilar, Aug 22, 2008
  2. 2/2 git-submodule: add "sync" commandDavid Aguilar, Aug 22, 2008
  3. Junio C HamanoAug 22, 2008
  4. Junio C HamanoAug 22, 2008
  5. Mark LevedahlAug 23, 2008
  6. Junio C HamanoAug 23, 2008
  7. Mark LevedahlAug 23, 2008
  8. Junio C HamanoAug 23, 2008

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.