From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389096; b=v0OwHi7sTgXuEitXwFP3cH15dPsSAuhY7KN9uHsf9C8gTbeQlx2o5tMlLmw4100C4CBI Xfq+tDtJ5e/Q9KKcZaPfD8k1B+h5l49YOLGKr8NzxiktsKC+l1d3lcnVFPgESws6soMI+ AbNJbXkT+l2H2FsRJgEGBRA8HLhJ0TOUnx9INh5TY6Sdb7CUOPAi6JE/6rNHRE+Cfeely eJubJWkWK3K/2GVCksBHDAC3OOjD9HJTeDhNvvVUNiAhDpCw/gMZTqfKPby7mL5ccQk4h AlMIY3q/NDfg0K9bA71U4fyzotPfidgZHOO6205qQF1QOfxfA6dRcIoP+d54EUK9NUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389096; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To: References:From:Date:Subject:Fcc:Content-Type: Content-Transfer-Encoding:MIME-Version:To:Cc; bh=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=; b=irgB0qsPg1Jz4B8rvQ4Ovk5sNvpbxKJiGd2wK2rwr3a2QwvOHNgV0frcyyhLQ/gWE2iY tVufb4O8F24riIXE1JUgGKzoHjVb7GHw/vtg41eomStpqPdct4m6n7XmBmV2K1u6dK8Al cHjhCrhctKbytqmAhPm1UxCLhBRcnS+gDNlctSo4RHpzKbE0GxJ2PC2fjUe6q2v4sSUW6 AI744HIoDU3857q/QDJbEAqo1V4EGra52aklauxUQmHspDU9HmSJTZvoPTcwHOfNsJWQj Q5YOhzlNKQLgTxNcWhhtbvVRT5ZcSxtVUbKPSlBomLkNQeThjNlIoWUL3WQFAzzDkLA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oqGLwduM; arc=none smtp.remote-ip=209.85.216.43 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33DA4606A684 for ; Fri, 4 Dec 2026 12:58:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33DA4606A684 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oqGLwduM Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-3b542b4d7bcso447226a91.0 for ; Fri, 04 Dec 2026 04:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796389095; x=1796993895; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=; b=oqGLwduMS7GcDsqiFOxtD3FYFR377OEW2vxY2bT+BW3ZoN0lls/7bg4wU01nR6xCbA jMWLwb3TODlAOT7pZ6OOZ4UbvehYctOcLiCd8jkJCV9KUTz4sO+4+waqv8IeCimSz9/8 fPsuvouqgmPUCaH6atwN8b1MPk8NlrmRod5es2NBFmhbRB+xIwWRAy2hUL+SBDcI4n3A sD5f36yHIBHex9yKrbL3aElck9HO05KafQ7Jw6VS56qnf7h4rz6RQNwzw3nCcWaxRUEk iSMsH3saRGH6SITVY9mKSABPxblhU4OsNAQnyyFUUUqaFbEzVfqtwqX8lCcytnQci3uS 9q2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796389095; x=1796993895; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=; b=Lrf8k4PbureDd+x30Bzz8kc8lCK63I9Jk+zOzuatTRByO9uSez96HU3pbKz2ng0QtZ /U6npV7FTR9lyOJkPImkRdS2ve7P4z6hjix0rVDgyEhHVVDCseG0HHfHdKMGWkw1LuY7 XpunrEfM++z3kWO8e0uyrSs5HVaMcUHwISPte4uGjZLDWF4Q+CjYrUXOpMWOvY9wRdax xos6R60bwpKc30r7cUJ5PaIyC/i9+OMK4IFjLCr6yQclUnCf9cKRsz8iQFyA4jso4rNE 3IFZ/jINjghVUynL9lXu+GEGTgdJMsukEsERxZDi9iDaqtrsWcHNOkCYkYZIhh2p6DF7 5sIg== X-Gm-Message-State: AB4q+uEui0fdijNIM6FQhsC9DVjaD7sHIOITrlJxXRfD9ySzsCuqzbTH 4CwdaJg5LFli7Qqjd0+/SgcCsBc0b/kIHVkg3wqj/QTK4Ja+3qj4Cg8aVjkeYg== X-Gm-Gg: AZFdTZfxTp6qsQyl0zfjMOIGe1sHFA6fpWZbXFzKcVbK1aM00uFiHTiX52AnfQRNUXG s5GpcxCdpQNpq7hroksRwBjQhkSubkVsEYNIbpvK1btbRO4sFWnIWdWbGcOjWWkhdRMvR/vk+la CPQc48FVaN4Rdu+6c0eTaFEsiGeXWAO3rA/ZanbtRbapQvMDsEdisEAxALMT9I5IVZQSQXKGA8S Roni5rEEV57TD8hUJF8ugWOvPsSwqmEBDWWpQUqbs8sOekOsVZNrDC89xzRs1RkOOYwgDqlx6Mx +leQjZlPpgNYzDIhW+7RL16StV3nH00L6jOALJfYotqyT1kkeYFhRpTZvSNYbWGMWC/liBka8Lh JZCi4YaDiTDwJKcliiDbMOrj5Q/pPIzSHDxHMCcV0gaVQ40Kmi6MynCC5wpZHklRIGuhwGiK0BS 7aOA0KALtYeHBkfFSsyT4r5kPsnnu6vm/Ts/HMLFJ8aT1UUNhDFZvhh3PCg8CClWQWyjUl8Yguu LflmayBoJK6lkTcGg/IjpzugxrJJ+Tm5J6fcwH2AHcTtZLiK0SMbzPHI4XGIdNiiLK0ogK2dq2/ TOyIGSaRZZckiQKAfTLGl0GX3UrnyALE X-Received: by 2002:a17:90b:1dc1:b0:3a8:545a:9e87 with SMTP id 98e67ed59e1d1-3b5e061bf17mr1657228a91.15.1796389095288; Fri, 04 Dec 2026 04:58:15 -0800 (PST) Received: from [127.0.0.1] ([4.149.246.120]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddb881bfsm3935438a91.1.2026.12.04.04.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 04:58:14 -0800 (PST) Message-Id: <69aed73e2301ea590fff4aa4cbefa4f4d64b1d86.1796389090.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Fri, 04 Dec 2026 12:58:09 +0000 Subject: [PATCH v6 3/4] status: preserve customized submodule remotes Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 To: git@vger.kernel.org Cc: "D. Ben Knoble" , Alessio Attilio , Alessio Attilio From: Alessio Attilio Users may point a populated submodule remote at a fork. Since git submodule sync would overwrite custom or multi-URL remotes, suppress the advice unless the configured remote matches the old or declared URL. Signed-off-by: Alessio Attilio --- wt-status.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/wt-status.c b/wt-status.c index bbd0e082dc..69c05735ec 100644 --- a/wt-status.c +++ b/wt-status.c @@ -2696,6 +2696,85 @@ static void wt_porcelain_v2_print(struct wt_status *s) } } +static int submodule_has_custom_remote_url(struct repository *repo, + const char *path, + const char *declared_url, + const char *cached_url) +{ + struct repository subrepo = { 0 }; + const struct string_list *remote_urls = NULL; + const char *remote; + const char *remote_url; + char *key, *up_path, *config_remote_url, *gitmodules_remote_url; + char *declared_super_url; + char *worktree_path; + int error_code, populated, ret = 0; + + worktree_path = repo_worktree_path(repo, "%s", path); + if (!worktree_path) + return 0; + populated = is_submodule_populated_gently(worktree_path, &error_code); + free(worktree_path); + if (!populated) + return 0; + + if (repo_submodule_init(&subrepo, repo, path, + null_oid(repo->hash_algo)) < 0) { + repo_clear(&subrepo); + return 0; + } + + declared_super_url = resolve_submodule_url(repo, declared_url, NULL, 1); + remote = repo_remote_from_url(&subrepo, declared_super_url); + if (!remote) + remote = repo_default_remote(&subrepo); + free(declared_super_url); + + key = xstrfmt("remote.%s.url", remote); + if (!repo_config_get_string_multi(&subrepo, key, &remote_urls) && + remote_urls->nr == 1 && + (remote_url = remote_urls->items[0].string)) { + up_path = get_submodule_up_path(path); + /* + * sync_submodule() stores a relative URL in the superproject's + * config without the submodule path prefix, but adds that prefix + * when storing the URL in the submodule's remote configuration. + */ + if (url_is_local_not_ssh(cached_url) && + !is_absolute_path(cached_url)) { + struct strbuf sb = STRBUF_INIT; + + strbuf_addstr(&sb, up_path); + strbuf_addstr(&sb, cached_url); + config_remote_url = strbuf_detach(&sb, NULL); + } else { + config_remote_url = xstrdup(cached_url); + } + gitmodules_remote_url = resolve_submodule_url(repo, declared_url, + up_path, 1); + /* + * The submodule's remote URL may be a local fork. If it matches + * neither the old cached URL nor the new .gitmodules URL, leave it + * alone; syncing would overwrite that customization. + */ + ret = strcmp(remote_url, config_remote_url) != 0 && + strcmp(remote_url, gitmodules_remote_url) != 0; + free(gitmodules_remote_url); + free(config_remote_url); + free(up_path); + } else { + /* + * Multiple URLs are a local customization; sync would replace + * them all with a single URL. + */ + ret = remote_urls && remote_urls->nr > 1; + } + free(key); + repo_clear(&subrepo); + + return ret; +} + static void wt_status_check_submodule_urls(struct wt_status *s) { int i; @@ -2734,7 +2813,10 @@ static void wt_status_check_submodule_urls(struct wt_status *s) free(key); gitmodules_url = resolve_submodule_url(s->repo, sub->url, NULL, 1); - if (strcmp(config_url, gitmodules_url)) + if (strcmp(config_url, gitmodules_url) && + !submodule_has_custom_remote_url(s->repo, ce->name, + sub->url, + config_url)) warning(_("submodule '%s' has a different URL in .git/config " "than in .gitmodules\n" " run 'git submodule sync' to update it"), ce->name); -- gitgitgadget