@@ -47,8 +47,8 @@ def parse(args)
4747 options [ :nominimizeurl ] = false
4848 options [ :rootistrunk ] = false
4949 options [ :trunk ] = 'trunk'
50- options [ :branches ] = 'branches'
51- options [ :tags ] = 'tags'
50+ options [ :branches ] = [ ]
51+ options [ :tags ] = [ ]
5252 options [ :exclude ] = [ ]
5353 options [ :revision ] = nil
5454 options [ :username ] = nil
@@ -83,12 +83,12 @@ def parse(args)
8383 options [ :trunk ] = trunk
8484 end
8585
86- opts . on ( '--branches BRANCHES_PATH' , 'Subpath to branches from repository URL (default: branches)' ) do |branches |
87- options [ :branches ] = branches
86+ opts . on ( '--branches BRANCHES_PATH' , 'Subpath to branches from repository URL (default: branches); can be used multiple times ' ) do |branches |
87+ options [ :branches ] << branches
8888 end
8989
90- opts . on ( '--tags TAGS_PATH' , 'Subpath to tags from repository URL (default: tags)' ) do |tags |
91- options [ :tags ] = tags
90+ opts . on ( '--tags TAGS_PATH' , 'Subpath to tags from repository URL (default: tags); can be used multiple times ' ) do |tags |
91+ options [ :tags ] << tags
9292 end
9393
9494 opts . on ( '--rootistrunk' , 'Use this if the root level of the repo is equivalent to the trunk and there are no tags or branches' ) do
@@ -182,28 +182,42 @@ def clone!
182182 if rootistrunk
183183 # Non-standard repository layout. The repository root is effectively 'trunk.'
184184 cmd = "git svn init --prefix=svn/ "
185- cmd += "--username=#{ username } " unless username . nil?
186- cmd += "--password=#{ password } " unless password . nil?
185+ cmd += "--username=' #{ username } ' " unless username . nil?
186+ cmd += "--password=' #{ password } ' " unless password . nil?
187187 cmd += "--no-metadata " unless metadata
188188 if nominimizeurl
189189 cmd += "--no-minimize-url "
190190 end
191- cmd += "--trunk=#{ @url } "
191+ cmd += "--trunk=' #{ @url } ' "
192192 run_command ( cmd , true , true )
193193
194194 else
195195 cmd = "git svn init --prefix=svn/ "
196196
197197 # Add each component to the command that was passed as an argument.
198- cmd += "--username=#{ username } " unless username . nil?
199- cmd += "--password=#{ password } " unless password . nil?
198+ cmd += "--username=' #{ username } ' " unless username . nil?
199+ cmd += "--password=' #{ password } ' " unless password . nil?
200200 cmd += "--no-metadata " unless metadata
201201 if nominimizeurl
202202 cmd += "--no-minimize-url "
203203 end
204- cmd += "--trunk=#{ trunk } " unless trunk . nil?
205- cmd += "--tags=#{ tags } " unless tags . nil?
206- cmd += "--branches=#{ branches } " unless branches . nil?
204+ cmd += "--trunk='#{ trunk } ' " unless trunk . nil?
205+ unless tags . nil?
206+ # Fill default tags here so that they can be filtered later
207+ tags = [ 'tags' ] if tags . empty?
208+ # Process default or user-supplied tags
209+ tags . each do |tag |
210+ cmd += "--tags='#{ tag } ' "
211+ end
212+ end
213+ unless branches . nil?
214+ # Fill default branches here so that they can be filtered later
215+ branches = [ 'branches' ] if branches . empty?
216+ # Process default or user-supplied branches
217+ branches . each do |branch |
218+ cmd += "--branches='#{ branch } ' "
219+ end
220+ end
207221
208222 cmd += @url
209223
@@ -224,8 +238,8 @@ def clone!
224238 regex = [ ]
225239 unless rootistrunk
226240 regex << "#{ trunk } [/]" unless trunk . nil?
227- regex << "#{ tags } [/][^/]+[/]" unless tags . nil?
228- regex << "#{ branches } [/][^/]+[/]" unless branches . nil?
241+ tags . each { | tag | regex << "#{ tag } [/][^/]+[/]" } unless tags . nil? or tags . empty ?
242+ branches . each { | branch | regex << "#{ branch } [/][^/]+[/]" } unless branches . nil? or branches . empty ?
229243 end
230244 regex = '^(?:' + regex . join ( '|' ) + ')(?:' + exclude . join ( '|' ) + ')'
231245 cmd += "--ignore-paths='#{ regex } ' "
0 commit comments