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

Re: How to get rid of doubled branch after renaming a branch in svn-repository

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Dec 1, 2010, 14:01 UTC
Message-ID
<4CF6553C.70500@drmicha.warpmail.net>
In-Reply-To
<0a6b49e3cc0b08a717c0d6141073f32d@tropezien.de>
pacco@tropezien.de venit, vidit, dixit 01.12.2010 13:48:
Show 36 quoted lines
>  Hi,
> 
>  I'm using git-svn as a tracking-tool for a Subversion repository.
>  I currently detected an unexpected branch, seeming dead, but visible 
>  using 'git branch -a'. I checked the svn log and saw that someone has 
>  moved/renamed a branch. That results in a deletion of the old branch and 
>  an adding of a copy of the old branch with the new branch name.
> 
>  The scenario is like that:
> 
>  $ git branch -a
>  * master
>    remotes/svnrepos/git-svn-test
> 
>  # Rename the branch (move) in the SVN-repos
>  $ svn mv https://svn.repos/branches/git-svn-test 
>  https://svn.repos/branches/git-svn-test-new
> 
>  # Update git-repository
>  $ git svn fetch
> 
>  $ git branch -a
>  * master
>    remotes/svnrepos/git-svn-test
>    remotes/svnrepos/git-svn-test-new
> 
>  You see the problem. Within Subversion simply a new repository version 
>  now no longer "showing" the git-svn-test-branch was created. But within 
>  git both branches stay visible.
>  Well, I know that renaming a branch is really not that favoured action.
>  But I expected that git-svn gathers also this deletion and removes the 
>  obsolete branch.
> 
>  So, am I doing something wrong? Or am I expecting the wrong behaviour? 
>  Or is that simply a feature, not a bug, and must be handled manually?
> 

Branches in svn and git are different. If you delete a branch in svn, the "content" is still there in the sense that it is there in previous revisions. You only delete a pointer in your svn-filesystem.

In git, a branch points at a commit, and deleting a branch means making that commit pointerless (unless it is pointed to by other branches or tags). So far there's some similarity. But now, if that commit and all its descendants are "pointerless" (can't be reached from a named ref) git will garbage collect them after a while. They're considered pointless ;)

svn records the rename as a copy+delete (it also sets some rename info which git-svn seems to ignore). So, git-svn stays on the safe side by keeping the branch. Note that deleting the branch would possibly delete at least some info since the branch name is not recorded in the commit (if you use svn.noMetadata).

You can safely delete the branch if you're sure its head commit is contained in some other branch (as will be for an ordinary rename).

Michael
Previous: pacco@tropezien.deNext: pacco@tropezien.de
Message 2 of 3 in “How to get rid of doubled branch after renaming a branch in svn-repository”
  1. pacco@tropezien.deDec 1, 2010
  2. Michael J GruberDec 1, 2010
  3. pacco@tropezien.deDec 1, 2010

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.