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.