Re: [PATCH v3 08/13] submodule--helper run-update-procedure: learn --remote
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 3, 2022, 21:35 UTC
- Message-ID
- <xmqq4k4eafdf.fsf@gitster.g>
- In-Reply-To
- <20220303005727.69270-9-chooglen@google.com>
Glen Choo <chooglen@google.com> writes:
Show 22 quoted lines
> @@ -3033,6 +3004,25 @@ static int update_submodule2(struct update_data *update_data)
> die(_("Unable to find current revision in submodule path '%s'"),
> update_data->displaypath);
>
> + if (update_data->remote) {
> + char *remote_name = get_default_remote_submodule(update_data->sm_path);
> + const char *branch = remote_submodule_branch(update_data->sm_path);
> + char *remote_ref = xstrfmt("refs/remotes/%s/%s", remote_name, branch);
> +
> + if (!update_data->nofetch) {
> + if (fetch_in_submodule(update_data->sm_path, update_data->depth,
> + 0, NULL))
> + die(_("Unable to fetch in submodule path '%s'"),
> + update_data->sm_path);
> + }
> +
> + if (resolve_gitlink_ref(update_data->sm_path, remote_ref, &update_data->oid))
> + die(_("Unable to find %s revision in submodule path '%s'"),
> + remote_ref, update_data->sm_path);
> +
> + free(remote_ref);
> + }This, and ...
Show 18 quoted lines
> @@ -409,21 +395,6 @@ cmd_update()
> just_cloned=
> fi
>
> - if test -n "$remote"
> - then
> - branch=$(git submodule--helper remote-branch "$sm_path")
> - if test -z "$nofetch"
> - then
> - # Fetch remote before determining tracking $sha1
> - fetch_in_submodule "$sm_path" $depth ||
> - die "fatal: $(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
> - fi
> - remote_name=$(sanitize_submodule_env; cd "$sm_path" && git submodule--helper print-default-remote)
> - sha1=$(sanitize_submodule_env; cd "$sm_path" &&
> - git rev-parse --verify "${remote_name}/${branch}") ||
> - die "fatal: $(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
> - fi... this change would "fix" the temporary breakage [05/13] may have brought us. From the series structure's point of view, doing [05/13] after this would be more sensible. If we leave the call to "displaypath" still in the script after this series, [05/13] or its equivalent should mention that ensure-core-worktree does not matter for that particular call when it delays the call to it by moving it to the beginning of the update_submodule2() from the much earlier part of the script.
Show 10 quoted lines
> out=$(git submodule--helper run-update-procedure \
> ${wt_prefix:+--prefix "$wt_prefix"} \
> ${GIT_QUIET:+--quiet} \
> @@ -434,6 +405,7 @@ cmd_update()
> ${update:+--update "$update"} \
> ${prefix:+--recursive-prefix "$prefix"} \
> ${sha1:+--oid "$sha1"} \
> + ${remote:+--remote} \
> "--" \
> "$sm_path")