Subject: Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

From: Junio C Hamano <[email-masked]>
Date: Tue, 07 Jan 2025 08:49:37 -0800

Junio C Hamano <[email-masked]> writes:

> Patrick Steinhardt <[email-masked]> writes:
>
>> Makes sense indeed. We can easily add for something like below diff.
>> I'll roll that into the next version, thanks!
>
> It is a good start, but is probably a bit too noisy.  Can we make
> them appear ONLY when the definitions read from these older sources
> are actually USED?
>
> Thanks.

Something along this line is what I had in mind.  Not even compile
tested, and I am not claiming that all the uses of remote will go
thourgh the code paths to use it with a transport, but you hopefully
got the idea.

 remote.c    | 20 ++++++++++++++++++++
 remote.h    |  2 ++
 transport.c |  2 ++
 3 files changed, 24 insertions(+)

diff --git c/remote.c w/remote.c
index f43cf5e7a4..1cca98215d 100644
--- c/remote.c
+++ w/remote.c
@@ -2904,3 +2904,23 @@ char *relative_url(const char *remote_url, const char *url,
 	free(out);
 	return strbuf_detach(&sb, NULL);
 }
+
+void remote_stale_warning(const struct remote *remote)
+{
+	const char *msg;
+
+	switch (remote->origin) {
+	case REMOTE_REMOTES:
+		msg = N_("Using remote '%s' read from the .git/remotes, "
+			 "whose support will be removed");
+		break;
+	case REMOTE_BRANCHES:
+		msg = N_("Using remote '%s' read from the .git/branches, "
+			 "whose support will be removed");
+		break;
+	default:
+		return;
+	}
+
+	warning(_(msg), remote->name);
+}
diff --git c/remote.h w/remote.h
index b901b56746..e29ceef3e4 100644
--- c/remote.h
+++ w/remote.h
@@ -445,4 +445,6 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
 		   const char *up_path);
 
+void remote_stale_warning(const struct remote *remote);
+
 #endif
diff --git c/transport.c w/transport.c
index 12cc5b4d96..c153be9100 100644
--- c/transport.c
+++ w/transport.c
@@ -1131,6 +1131,8 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	ret->remote = remote;
 	helper = remote->foreign_vcs;
 
+	remote_stale_warning(remote);
+
 	if (!url)
 		url = remote->url.v[0];
 	ret->url = url;