Skip to content

Commit b8e700e

Browse files
committed
Merge branch 'submodule_fix' of https://github.com/Javex/GitPython into Javex-submodule_fix
2 parents 539980d + 5385cbd commit b8e700e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

git/repo/base.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ def _set_alternates(self, alts):
563563
alternates = property(_get_alternates, _set_alternates,
564564
doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")
565565

566-
def is_dirty(self, index=True, working_tree=True, untracked_files=False):
566+
def is_dirty(self, index=True, working_tree=True, untracked_files=False,
567+
consider_submodules=True):
567568
"""
568569
:return:
569570
``True``, the repository is considered dirty. By default it will react
@@ -575,7 +576,9 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False):
575576
return False
576577

577578
# start from the one which is fastest to evaluate
578-
default_args = ('--abbrev=40', '--full-index', '--raw')
579+
default_args = ['--abbrev=40', '--full-index', '--raw']
580+
if not consider_submodules:
581+
default_args.append('--ignore-submodules')
579582
if index:
580583
# diff index against HEAD
581584
if isfile(self.index.path) and \
@@ -588,7 +591,10 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False):
588591
return True
589592
# END working tree handling
590593
if untracked_files:
591-
if len(self.untracked_files):
594+
kwargs = {}
595+
if not consider_submodules:
596+
kwargs['ignore_submodules'] = True
597+
if len(self._get_untracked_files(**kwargs)):
592598
return True
593599
# END untracked files
594600
return False
@@ -604,10 +610,14 @@ def untracked_files(self):
604610
605611
:note:
606612
ignored files will not appear here, i.e. files mentioned in .gitignore"""
613+
return self._get_untracked_files()
614+
615+
def _get_untracked_files(self, **kwargs):
607616
# make sure we get all files, no only untracked directores
608617
proc = self.git.status(porcelain=True,
609618
untracked_files=True,
610-
as_process=True)
619+
as_process=True,
620+
**kwargs)
611621
# Untracked files preffix in porcelain mode
612622
prefix = "?? "
613623
untracked_files = list()

0 commit comments

Comments
 (0)