@@ -226,7 +226,8 @@ def remote(self, name='origin'):
226226
227227 @property
228228 def submodules (self ):
229- """:return: git.IterableList(Submodule, ...) of direct submodules"""
229+ """:return: git.IterableList(Submodule, ...) of direct submodules
230+ available from the current head"""
230231 return Submodule .list_items (self )
231232
232233 def submodule (self , name ):
@@ -238,68 +239,24 @@ def submodule(self, name):
238239 raise ValueError ("Didn't find submodule named %r" % name )
239240 # END exception handling
240241
242+ def create_submodule (self , * args , ** kwargs ):
243+ """Create a new submodule
244+ :note: See the documentation of Submodule.add for a description of the
245+ applicable parameters
246+ :return: created submodules"""
247+ return Submodule .add (self , * args , ** kwargs )
248+
241249 def iter_submodules (self , * args , ** kwargs ):
242250 """An iterator yielding Submodule instances, see Traversable interface
243251 for a description of args and kwargs
244252 :return: Iterator"""
245253 return RootModule (self ).traverse (* args , ** kwargs )
246254
247- def submodule_update (self , previous_commit = None , force_remove = False , to_latest_revision = False ):
248- """Update the submodules of this repository to the current HEAD commit.
249- This method behaves smartly by determining changes of the path of a submodules
250- repository, next to changes to the to-be-checked-out commit or the branch to be
251- checked out. This works if the submodules ID does not change.
252- Additionally it will detect addition and removal of submodules, which will be handled
253- gracefully.
254-
255- :param previous_commit: If set to a commit'ish, the commit we should use
256- as the previous commit the HEAD pointed to before it was set to the commit it points to now.
257- If None, it defaults to ORIG_HEAD otherwise, or the parent of the current
258- commit if it is not given
259- :param force_remove: If submodules have been deleted, they will be forcibly removed.
260- Otherwise the update may fail if a submodule's repository cannot be deleted as
261- changes have been made to it (see Submodule.update() for more information)
262- :param to_latest_revision: If True, instead of checking out the revision pointed to
263- by this submodule's sha, the checked out tracking branch will be merged with the
264- newest remote branch fetched from the repository's origin"""
265- if self .bare :
266- raise InvalidGitRepositoryError ("Cannot update submodules in bare repositories" )
267- # END handle bare
268-
269- # HANDLE COMMITS
270- ##################
271- cur_commit = self .head .commit
272- if previous_commit is None :
273- symref = SymbolicReference (self , SymbolicReference .to_full_path ('ORIG_HEAD' ))
274- try :
275- previous_commit = symref .commit
276- except Exception :
277- pcommits = cur_commit .parents
278- if pcommits :
279- previous_commit = pcommits [0 ]
280- else :
281- # in this special case, we just diff against ourselve, which
282- # means exactly no change
283- previous_commit = cur_commit
284- # END handle initial commit
285- # END no ORIG_HEAD
286- else :
287- previous_commit = self .commit (previous_commit ) # obtain commit object
288- # END handle previous commit
289-
290- sms = self .submodules ()
291-
292- # HANDLE REMOVALS
293-
294- # HANDLE PATH RENAMES
295-
296- # FINALLY UPDATE ALL ACTUAL SUBMODULES
297- ##########################################
298- if previous_commit == cur_commit :
299- for sm in sms :
300- sm .update (recursive = True , init = True , to_latest_revision = to_latest_revision )
301- # END for each submodule to update
302- # END handle commits are equal
255+ def submodule_update (self , * args , ** kwargs ):
256+ """Update the submodules, keeping the repository consistent as it will
257+ take the previous state into consideration. For more information, please
258+ see the documentation of RootModule.update"""
259+ return RootModule (self ).update (* args , ** kwargs )
303260
304261 #}END submodules
305262
0 commit comments