git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 11/11] PREVIEW: remove support for .git/remotes/ and .git/branches/

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 11, 2017, 13:48 UTC
Message-ID
<c73881261cc3021410695126989c6f1596f638b0.1494509599.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1494509599.git.johannes.schindelin@gmx.de>

At long last, after a cycle or three of warning users who *still* use the ancient feature of .git/remotes/ and .git/branches/, it is time to retire the code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 path.c   |  2 --
 remote.c | 96 ----------------------------------------------------------------
 remote.h |  4 +--
 3 files changed, 1 insertion(+), 101 deletions(-)
diff --git a/path.c b/path.c
index c1cb1cf6273..ee709bb2337 100644
--- a/path.c
+++ b/path.c
@@ -104,7 +104,6 @@ struct common_dir {
 };
 
 static struct common_dir common_list[] = {
-	{ 0, 1, 0, "branches" },
 	{ 0, 1, 0, "hooks" },
 	{ 0, 1, 0, "info" },
 	{ 0, 0, 1, "info/sparse-checkout" },
@@ -115,7 +114,6 @@ static struct common_dir common_list[] = {
 	{ 0, 1, 0, "objects" },
 	{ 0, 1, 0, "refs" },
 	{ 0, 1, 1, "refs/bisect" },
-	{ 0, 1, 0, "remotes" },
 	{ 0, 1, 0, "worktrees" },
 	{ 0, 1, 0, "rr-cache" },
 	{ 0, 1, 0, "svn" },
diff --git a/remote.c b/remote.c
index b2ae168035e..914ff74c0d2 100644
--- a/remote.c
+++ b/remote.c
@@ -241,89 +241,6 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
 	rewrite->instead_of_nr++;
 }
 
-static const char *skip_spaces(const char *s)
-{
-	while (isspace(*s))
-		s++;
-	return s;
-}
-
-static void read_remotes_file(struct remote *remote)
-{
-	struct strbuf buf = STRBUF_INIT;
-	FILE *f = fopen(git_path("remotes/%s", remote->name), "r");
-
-	if (!f)
-		return;
-
-	warning(_("the remote '%s' uses the long-deprecated '%s' file"),
-		remote->name, git_path("branches/%s", remote->name));
-
-	remote->configured_in_repo = 1;
-	remote->origin = REMOTE_REMOTES;
-	while (strbuf_getline(&buf, f) != EOF) {
-		const char *v;
-
-		strbuf_rtrim(&buf);
-
-		if (skip_prefix(buf.buf, "URL:", &v))
-			add_url_alias(remote, xstrdup(skip_spaces(v)));
-		else if (skip_prefix(buf.buf, "Push:", &v))
-			add_push_refspec(remote, xstrdup(skip_spaces(v)));
-		else if (skip_prefix(buf.buf, "Pull:", &v))
-			add_fetch_refspec(remote, xstrdup(skip_spaces(v)));
-	}
-	strbuf_release(&buf);
-	fclose(f);
-}
-
-static void read_branches_file(struct remote *remote)
-{
-	char *frag;
-	struct strbuf buf = STRBUF_INIT;
-	FILE *f = fopen(git_path("branches/%s", remote->name), "r");
-
-	if (!f)
-		return;
-
-	strbuf_getline_lf(&buf, f);
-	fclose(f);
-	strbuf_trim(&buf);
-	if (!buf.len) {
-		strbuf_release(&buf);
-		return;
-	}
-
-	warning(_("the branch '%s' uses the long-deprecated '%s' file"),
-		remote->name, git_path("branches/%s", remote->name));
-
-	remote->configured_in_repo = 1;
-	remote->origin = REMOTE_BRANCHES;
-
-	/*
-	 * The branches file would have URL and optionally
-	 * #branch specified.  The "master" (or specified) branch is
-	 * fetched and stored in the local branch matching the
-	 * remote name.
-	 */
-	frag = strchr(buf.buf, '#');
-	if (frag)
-		*(frag++) = '\0';
-	else
-		frag = "master";
-
-	add_url_alias(remote, strbuf_detach(&buf, NULL));
-	add_fetch_refspec(remote, xstrfmt("refs/heads/%s:refs/heads/%s",
-					  frag, remote->name));
-
-	/*
-	 * Cogito compatible push: push current HEAD to remote #branch
-	 * (master if missing)
-	 */
-	add_push_refspec(remote, xstrfmt("HEAD:refs/heads/%s", frag));
-	remote->fetch_tags = 1; /* always auto-follow */
-}
-
 static int handle_config(const char *key, const char *value, void *cb)
 {
 	const char *name;
@@ -652,13 +569,6 @@ void free_refspec(int nr_refspec, struct refspec *refspec)
 	free(refspec);
 }
 
-static int valid_remote_nick(const char *name)
-{
-	if (!name[0] || is_dot_or_dotdot(name))
-		return 0;
-	return !strchr(name, '/'); /* no slash */
-}
-
 const char *remote_for_branch(struct branch *branch, int *explicit)
 {
 	if (branch && branch->remote_name) {
@@ -700,12 +610,6 @@ static struct remote *remote_get_1(const char *name,
 		name = get_default(current_branch, &name_given);
 
 	ret = make_remote(name, 0);
-	if (valid_remote_nick(name) && have_git_dir()) {
-		if (!valid_remote(ret))
-			read_remotes_file(ret);
-		if (!valid_remote(ret))
-			read_branches_file(ret);
-	}
 	if (name_given && !valid_remote(ret))
 		add_url_alias(ret, name);
 	if (!valid_remote(ret))
diff --git a/remote.h b/remote.h
index 6c28cd3e4bf..921b3d43356 100644
--- a/remote.h
+++ b/remote.h
@@ -6,9 +6,7 @@
 
 enum {
 	REMOTE_UNCONFIGURED = 0,
-	REMOTE_CONFIG,
-	REMOTE_REMOTES,
-	REMOTE_BRANCHES
+	REMOTE_CONFIG
 };
 
 struct remote {
-- 
2.12.2.windows.2.800.gede8f145e06
Previous: Johannes SchindelinNext: Stefan Beller
Message 42 of 62 in “Start retiring .git/remotes/ and .git/branches/ for good”
  1. 00/11 Start retiring .git/remotes/ and .git/branches/ for goodJohannes Schindelin, May 11, 2017
  2. 05/11 Revert "Revert "Don't create the $GIT_DIR/branches directory on init""Johannes Schindelin, May 11, 2017
  3. Stefan BellerMay 11, 2017
  4. 04/11 remote: warn loud and clear when .git/remotes/ is *still* usedJohannes Schindelin, May 11, 2017
  5. 01/11 git-parse-remote: fix highly misleading man pageJohannes Schindelin, May 11, 2017
  6. Stefan BellerMay 11, 2017
  7. Johannes SchindelinMay 11, 2017
  8. 0/5 Remove now-unused git-parse-remoteÆvar Arnfjörð Bjarmason, Nov 11, 2020
  9. Jeff KingNov 11, 2020
  10. Junio C HamanoNov 11, 2020
  11. Ævar Arnfjörð BjarmasonNov 12, 2020
  12. Jeff KingNov 12, 2020
  13. How do I "git fetch" with a custom <refspec> but a default remote?Ævar Arnfjörð Bjarmason, Nov 12, 2020
  14. Jeff KingNov 12, 2020
  15. Chris TorekNov 12, 2020
  16. Jeff KingNov 12, 2020
  17. Junio C HamanoNov 12, 2020
  18. Ævar Arnfjörð BjarmasonNov 14, 2020
  19. 1/5 parse-remote: remove unused GIT_DIR variableÆvar Arnfjörð Bjarmason, Nov 11, 2020
  20. 2/5 parse-remote: remove long-dead rebase codeÆvar Arnfjörð Bjarmason, Nov 11, 2020
  21. 4/5 parse-remote: move used code to git-submodule.shÆvar Arnfjörð Bjarmason, Nov 11, 2020
  22. 5/5 parse-remote: remove this now-unused libraryÆvar Arnfjörð Bjarmason, Nov 11, 2020
  23. Junio C HamanoNov 11, 2020
  24. 0/2 Retire git-parse-remoteJunio C Hamano, Nov 12, 2020
  25. 1/2 parse-remote: move used code to git-submodule.shJunio C Hamano, Nov 12, 2020
  26. 2/2 parse-remote: remove this now-unused libraryJunio C Hamano, Nov 12, 2020
  27. Jeff KingNov 12, 2020
  28. Junio C HamanoNov 12, 2020
  29. Ævar Arnfjörð BjarmasonNov 13, 2020
  30. 0/3 submodule sh->C & retire parse-remoteÆvar Arnfjörð Bjarmason, Nov 14, 2020
  31. 1/3 submodule: use "fetch" logic instead of custom remote discoveryÆvar Arnfjörð Bjarmason, Nov 14, 2020
  32. Junio C HamanoNov 16, 2020
  33. 3/3 parse-remote: remove this now-unused libraryÆvar Arnfjörð Bjarmason, Nov 14, 2020
  34. Junio C HamanoNov 16, 2020
  35. Ævar Arnfjörð BjarmasonNov 17, 2020
  36. 2/3 submodule: remove sh function in favor of helperÆvar Arnfjörð Bjarmason, Nov 14, 2020
  37. 3/5 parse-remote: remove long-dead git-pull.sh codeÆvar Arnfjörð Bjarmason, Nov 11, 2020
  38. 03/11 remote: warn loud and clear when .git/branches/ is *still* usedJohannes Schindelin, May 11, 2017
  39. 09/11 PREVIEW: t5515: remove .git/remotes/ and .git/branches/ testsJohannes Schindelin, May 11, 2017
  40. 02/11 Documentation: really deprecate .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  41. 10/11 PREVIEW: t0060: stop testing support for .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  42. 11/11 PREVIEW: remove support for .git/remotes/ and .git/branches/Johannes Schindelin, May 11, 2017
  43. Stefan BellerMay 11, 2017
  44. Johannes SchindelinMay 11, 2017
  45. 06/11 PREVIEW: t5510: convert .git/remotes/ test to use a regular remoteJohannes Schindelin, May 11, 2017
  46. 07/11 PREVIEW: t5516: stop testing .git/branches/ functionalityJohannes Schindelin, May 11, 2017
  47. 08/11 PREVIEW: remote: remove support for migrating ancient remotesJohannes Schindelin, May 11, 2017
  48. Junio C HamanoMay 12, 2017
  49. Johannes SchindelinMay 12, 2017
  50. Junio C HamanoMay 16, 2017
  51. Ævar Arnfjörð BjarmasonMay 16, 2017
  52. Junio C HamanoMay 16, 2017
  53. Ævar Arnfjörð BjarmasonMay 16, 2017
  54. Junio C HamanoMay 17, 2017
  55. Junio C HamanoMay 12, 2017
  56. Johannes SchindelinMay 12, 2017
  57. Jonathan NiederMay 12, 2017
  58. Junio C HamanoMay 13, 2017
  59. Junio C HamanoMay 12, 2017
  60. Johannes SchindelinMay 15, 2017
  61. Jeff KingMay 12, 2017
  62. Johannes SchindelinMay 12, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.