@@ -210,13 +210,14 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
210210 If None, the repository is assumed to exist, and the url of the first
211211 remote is taken instead. This is useful if you want to make an existing
212212 repository a submodule of anotherone.
213- :param branch: branch at which the submodule should (later) be checked out.
213+ :param branch: name of branch at which the submodule should (later) be checked out.
214214 The given branch must exist in the remote repository, and will be checked
215215 out locally as a tracking branch.
216216 It will only be written into the configuration if it not None, which is
217217 when the checked out branch will be the one the remote HEAD pointed to.
218218 The result you get in these situation is somewhat fuzzy, and it is recommended
219- to specify at least 'master' here
219+ to specify at least 'master' here.
220+ Examples are 'master' or 'feature/new'
220221 :param no_checkout: if True, and if the repository has to be cloned manually,
221222 no checkout will be performed
222223 :return: The newly created submodule instance
@@ -252,7 +253,8 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
252253 # END handle exceptions
253254 # END handle existing
254255
255- br = git .Head .to_full_path (str (branch ) or cls .k_head_default )
256+ # fake-repo - we only need the functionality on the branch instance
257+ br = git .Head (repo , git .Head .to_full_path (str (branch ) or cls .k_head_default ))
256258 has_module = sm .module_exists ()
257259 branch_is_default = branch is None
258260 if has_module and url is not None :
@@ -276,7 +278,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
276278 # clone new repo
277279 kwargs = {'n' : no_checkout }
278280 if not branch_is_default :
279- kwargs ['b' ] = br
281+ kwargs ['b' ] = br . name
280282 # END setup checkout-branch
281283 mrepo = git .Repo .clone_from (url , path , ** kwargs )
282284 # END verify url
@@ -290,8 +292,8 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
290292 sm ._url = url
291293 if not branch_is_default :
292294 # store full path
293- writer .set_value (cls .k_head_option , br )
294- sm ._branch_path = br
295+ writer .set_value (cls .k_head_option , br . path )
296+ sm ._branch_path = br . path
295297 # END handle path
296298 del (writer )
297299
0 commit comments