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

[PATCH 3/4] git-remote rename: support branches->config migration

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Nov 12, 2008, 17:11 UTC
Message-ID
<c3744d00a3d612a637cf520d2719492265e4f061.1226508805.git.vmiklos@frugalware.org>
In-Reply-To
<d99804ad3579d4882e8241d9dcaee1b7dd6508af.1226508805.git.vmiklos@frugalware.org>

This is similar to the remotes->config one, but it makes the branches->config conversion possible.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-remote.c  |    6 +++++-
 t/t5505-remote.sh |   12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 4fa64a2..5b525c7 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -384,6 +384,8 @@ static int migrate_file(struct remote *remote)
 					remote->fetch_refspec[i], buf.buf);
 	if (remote->origin == REMOTE_REMOTES)
 		path = git_path("remotes/%s", remote->name);
+	else if (remote->origin == REMOTE_BRANCHES)
+		path = git_path("branches/%s", remote->name);
 	if (path && unlink(path))
 		warning("failed to remove '%s'", path);
 	return 0;
@@ -411,7 +413,9 @@ static int mv(int argc, const char **argv)
 	if (!oldremote)
 		die("No such remote: %s", rename.old);
 
-	if (!strcmp(rename.old, rename.new) && oldremote->origin == REMOTE_REMOTES)
+	if (!strcmp(rename.old, rename.new) &&
+			(oldremote->origin == REMOTE_REMOTES ||
+			 oldremote->origin == REMOTE_BRANCHES))
 		return migrate_file(oldremote);
 
 	newremote = remote_get(rename.new);
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 1567631..1f59960 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -364,4 +364,16 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
 	 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
 '
 
+test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
+	git clone one six &&
+	origin_url=$(pwd)/one &&
+	(cd six &&
+	 git remote rm origin &&
+	 echo "$origin_url" > .git/branches/origin &&
+	 git remote rename origin origin &&
+	 ! test -f .git/branches/origin &&
+	 test "$(git config remote.origin.url)" = "$origin_url" &&
+	 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
+'
+
 test_done
-- 
1.6.0.2
Previous: Miklos VajnaNext: Miklos Vajna
Message 4 of 5 in “git-remote rename: support branches->config migration”
  1. 0/4 git-remote rename: support branches->config migrationMiklos Vajna, Nov 12, 2008
  2. 1/4 remote: add a new 'origin' variable to the structMiklos Vajna, Nov 12, 2008
  3. 2/4 git-remote rename: support remotes->config migrationMiklos Vajna, Nov 12, 2008
  4. 3/4 git-remote rename: support branches->config migrationMiklos Vajna, Nov 12, 2008
  5. 4/4 git-remote: document the migration feature of the rename subcommandMiklos Vajna, Nov 12, 2008

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.