@@ -572,14 +572,14 @@ def move(self, module_path, configuration=True, module=True):
572572 the repository at our current path, changing the configuration, as well as
573573 adjusting our index entry accordingly.
574574
575- :param module_path: the path to which to move our module in the parent repostory's working tree,
575+ :param module_path: the path to which to move our module in the parent repostory's working tree,
576576 given as repository-relative or absolute path. Intermediate directories will be created
577577 accordingly. If the path already exists, it must be empty.
578578 Trailing (back)slashes are removed automatically
579579 :param configuration: if True, the configuration will be adjusted to let
580580 the submodule point to the given path.
581581 :param module: if True, the repository managed by this submodule
582- will be moved as well. If False, we don't move the submodule's checkout, which may leave
582+ will be moved as well. If False, we don't move the submodule's checkout, which may leave
583583 the parent repository in an inconsistent state.
584584 :return: self
585585 :raise ValueError: if the module path existed and was not empty, or was a file
@@ -672,7 +672,7 @@ def move(self, module_path, configuration=True, module=True):
672672return self
673673
674674@unbare_repo
675- def remove (self ,module = True ,force = False ,configuration = True ,dry_run = False , _is_recursive = False ):
675+ def remove (self ,module = True ,force = False ,configuration = True ,dry_run = False ):
676676"""Remove this submodule from the repository. This will remove our entry
677677 from the .gitmodules file and the entry in the .git/config file.
678678
@@ -695,7 +695,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False, _i
695695 we would usually throw
696696 :return: self
697697 :note: doesn't work in bare repositories
698- :note: doesn't work atomically, as failure to remove any part of the submodule will leave
698+ :note: doesn't work atomically, as failure to remove any part of the submodule will leave
699699 an inconsistent state
700700 :raise InvalidGitRepositoryError: thrown if the repository cannot be deleted
701701 :raise OSError: if directories or files could not be removed"""
@@ -704,10 +704,17 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False, _i
704704# END handle parameters
705705
706706# Recursively remove children of this submodule
707+ nc = 0
707708for csm in self .children ():
708- csm .remove (module ,force ,configuration ,dry_run ,_is_recursive = True )
709+ nc += 1
710+ csm .remove (module ,force ,configuration ,dry_run )
709711del (csm )
710- # end
712+ # end
713+ if nc > 0 :
714+ # Assure we don't leave the parent repository in a dirty state, and commit our changes
715+ # It's important for recursive, unforced, deletions to work as expected
716+ self .module ().index .commit ("Removed submodule '%s'" % self .name )
717+ # end handle recursion
711718
712719# DELETE REPOSITORY WORKING TREE
713720################################
@@ -733,7 +740,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False, _i
733740# END apply deletion method
734741else :
735742# verify we may delete our module
736- if mod .is_dirty (untracked_files = True ):
743+ if mod .is_dirty (index = True , working_tree = True , untracked_files = True ):
737744raise InvalidGitRepositoryError (
738745"Cannot delete module at %s with any modifications, unless force is specified"
739746% mod .working_tree_dir )
@@ -743,7 +750,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False, _i
743750# NOTE: If the user pulled all the time, the remote heads might
744751# not have been updated, so commits coming from the remote look
745752# as if they come from us. But we stay strictly read-only and
746- # don't fetchbeforhand .
753+ # don't fetchbeforehand .
747754for remote in mod .remotes :
748755num_branches_with_new_commits = 0
749756rrefs = remote .refs
@@ -794,15 +801,10 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False, _i
794801writer = self .repo .config_writer ()
795802writer .remove_section (sm_section (self .name ))
796803writer .release ()
804+
797805writer = self .config_writer ()
798806writer .remove_section ()
799807writer .release ()
800-
801- # Assure we don't leave the parent repository in a dirty state, and commit our changes
802- # It's important for recursive, unforced, deletions to work as expected
803- if _is_recursive :
804- self .module ().index .commit ("Removed submodule '%s'" % self .name )
805- # end
806808# END delete configuration
807809
808810# void our data not to delay invalid access
@@ -875,16 +877,16 @@ def module(self):
875877 :raise InvalidGitRepositoryError: if a repository was not available. This could
876878 also mean that it was not yet initialized"""
877879# late import to workaround circular dependencies
878- module_path = self .abspath
880+ module_checkout_abspath = self .abspath
879881try :
880- repo = git .Repo (module_path )
882+ repo = git .Repo (module_checkout_abspath )
881883if repo != self .repo :
882884return repo
883885# END handle repo uninitialized
884886except (InvalidGitRepositoryError ,NoSuchPathError ):
885- raise InvalidGitRepositoryError ("No valid repository at %s" % self . path )
887+ raise InvalidGitRepositoryError ("No valid repository at %s" % module_checkout_abspath )
886888else :
887- raise InvalidGitRepositoryError ("Repository at %r was not yet checked out" % module_path )
889+ raise InvalidGitRepositoryError ("Repository at %r was not yet checked out" % module_checkout_abspath )
888890# END handle exceptions
889891
890892def module_exists (self ):