Re: [PATCH v7 2/3] submodule update: add --remote for submodule's upstream changes
Phil Hord <phil.hord@gmail.com> writes:
Show 32 quoted lines
>> + if test -n "$remote"
>> + then
>> + if test -z "$nofetch"
>> + then
>> + # Fetch remote before determining tracking $sha1
>> + (clear_local_git_env; cd "$sm_path" && git-fetch) ||
>
> You should 'git fetch $remote_name' here, and of course, initialize
> remote_name before this. But how can we know the remote_name in the
> first place? Is it safe to assume the submodule remote names will
> match those in the superproject?
>
>> + die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
>> + fi
>> + remote_name=$(get_default_remote)
>
> This get_default_remote finds the remote for the remote-tracking
> branch for HEAD in the superproject. It is possible that HEAD !=
> $branch, so we have very few clues to go on here to get a more
> reasonable answer, so I do not have any good suggestions to improve
> this.
>
> One option would be to find the remote given for
> submodule."$branch".merge, but this would suppose there is some
> remote-tracking branch configured in the submodule, and that is not
> likely to be the case.
>
>> + sha1=$(clear_local_git_env; cd "$sm_path" &&
>> + git rev-parse --verify "${remote_name}/${branch}") ||
>
> This does assume the submodule remote names will match those in the
> superproject. Is this safe?All good points. Thanks for reviewing.