Documentation/git-svn: Promote the use of --prefix in docs + examples

Currently, the git-svn defaults to using an empty prefix, which ends up placing the SVN-tracking refs directly in refs/remotes/*. This placement runs counter to Git's convention of placing remote-tracking branches in refs/remotes/$remote/*. Furthermore, combining git-svn with "regular" Git remotes run the risk of clobbering refs under refs/remotes (e.g. if you have a git remote called "tags" with a "v1" branch, it will overlap with the git-svn's tracking branch for the "v1" tag from Subversion. Even though the git-svn refs stored in refs/remotes/* are not "proper" remote-tracking branches (since they are not covered by a proper git remote's refspec), they clearly represent a similar concept, and would benefit from following the same convention. For example, if git-svn tracks Subversion branch "foo" at refs/remotes/foo, and you create a local branch refs/heads/foo to add some commits to be pushed back to Subversion (using "git svn dcommit), then it is clearly unhelpful of Git to throw warning: refname 'foo' is ambiguous. every time you checkout, rebase, or otherwise interact with the branch. At this time, the user is better off using the --prefix=foo/ (the trailing slash is important) to git svn init/clone, to cause the SVN-tracking refs to be placed at refs/remotes/foo/* instead of refs/remotes/*. This patch updates the documentation to encourage use of --prefix. This is also in preparation for changing the default value of --prefix at some point in the future. Cc: Eric Wong <normalperson@yhbt.net> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Eric Wong <normalperson@yhbt.net>

Johan Herland committed Oct 11, 2013 at 14:57 UTC 7091a2d0bfdea5a8e1c77027d746e06ae384bffa
1 file changed +25 -10
Documentation/git-svn.txt
+25 -10
@@ -79,8 +79,13 @@ COMMANDS
79 trailing slash, so be sure you include one in the
80 argument if that is what you want. If --branches/-b is
81 specified, the prefix must include a trailing slash.
82 - Setting a prefix is useful if you wish to track multiple
83 - projects that share a common repository.
82 + Setting a prefix (with a trailing slash) is strongly
83 + encouraged in any case, as your SVN-tracking refs will
84 + then be located at "refs/remotes/$prefix/*", which is
85 + compatible with Git's own remote-tracking ref layout
86 + (refs/remotes/$remote/*). Setting a prefix is also useful
87 + if you wish to track multiple projects that share a common
88 + repository.
89 --ignore-paths=<regex>;;
90 When passed to 'init' or 'clone' this regular expression will
91 be preserved as a config key. See 'fetch' for a description
@@ -811,16 +816,16 @@ Tracking and contributing to an entire Subversion-managed project
816
817 ------------------------------------------------------------------------
818 # Clone a repo with standard SVN directory layout (like git clone):
814 - git svn clone http://svn.example.com/project --stdlayout
819 + git svn clone http://svn.example.com/project --stdlayout --prefix svn/
820 # Or, if the repo uses a non-standard directory layout:
816 - git svn clone http://svn.example.com/project -T tr -b branch -t tag
821 + git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/
822 # View all branches and tags you have cloned:
823 git branch -r
824 # Create a new branch in SVN
825 git svn branch waldo
826 # Reset your master to trunk (or any other branch, replacing 'trunk'
827 # with the appropriate name):
823 - git reset --hard remotes/trunk
828 + git reset --hard svn/trunk
829 # You may only dcommit to one branch/tag/trunk at a time. The usage
830 # of dcommit/rebase/show-ignore should be the same as above.
831 ------------------------------------------------------------------------
@@ -834,7 +839,7 @@ have each person clone that repository with 'git clone':
839
840 ------------------------------------------------------------------------
841 # Do the initial import on a server
837 - ssh server "cd /pub && git svn clone http://svn.example.com/project
842 + ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]"
843 # Clone locally - make sure the refs/remotes/ space matches the server
844 mkdir project
845 cd project
@@ -847,8 +852,9 @@ have each person clone that repository with 'git clone':
852 git config --remove-section remote.origin
853 # Create a local branch from one of the branches just fetched
854 git checkout -b master FETCH_HEAD
850 -# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
851 - git svn init http://svn.example.com/project
855 +# Initialize 'git svn' locally (be sure to use the same URL and
856 +# --stdlayout/-T/-b/-t/--prefix options as were used on server)
857 + git svn init http://svn.example.com/project [options...]
858 # Pull the latest changes from Subversion
859 git svn rebase
860 ------------------------------------------------------------------------
@@ -980,6 +986,15 @@ without giving any repository layout options. If the full history with
986 branches and tags is required, the options '--trunk' / '--branches' /
987 '--tags' must be used.
988
989 +When using the options for describing the repository layout (--trunk,
990 +--tags, --branches, --stdlayout), please also specify the --prefix
991 +option (e.g. '--prefix=origin/') to cause your SVN-tracking refs to be
992 +placed at refs/remotes/origin/* rather than the default refs/remotes/*.
993 +The former is more compatible with the layout of Git's "regular"
994 +remote-tracking refs (refs/remotes/$remote/*), and may potentially
995 +prevent similarly named SVN branches and Git remotes from clobbering
996 +each other.
997 +
998 When using multiple --branches or --tags, 'git svn' does not automatically
999 handle name collisions (for example, if two branches from different paths have
1000 the same name, or if a branch and a tag have the same name). In these cases,
@@ -1042,8 +1057,8 @@ comma-separated list of names within braces. For example:
1057 [svn-remote "huge-project"]
1058 url = http://server.org/svn
1059 fetch = trunk/src:refs/remotes/trunk
1045 - branches = branches/{red,green}/src:refs/remotes/branches/*
1046 - tags = tags/{1.0,2.0}/src:refs/remotes/tags/*
1060 + branches = branches/{red,green}/src:refs/remotes/project-a/branches/*
1061 + tags = tags/{1.0,2.0}/src:refs/remotes/project-a/tags/*
1062 ------------------------------------------------------------------------
1063
1064 Multiple fetch, branches, and tags keys are supported: