Skip to content

Commit

Permalink
Properly support submodules in porcelain.status. Fixes #517
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jul 15, 2017
1 parent 461fe06 commit e174472
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
add from current working directory rather than repository root.
(Jelmer Vernooij, #521)

* Properly deal with submodules in 'porcelain.status'.
(Jelmer Vernooij, #517)

IMPROVEMENTS

* Add basic support for reading ignore files in ``dulwich.ignore``.
Expand Down
16 changes: 13 additions & 3 deletions dulwich/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ def get_unstaged_changes(index, root_path):

for tree_path, entry in index.iteritems():
full_path = _tree_to_fs_path(root_path, tree_path)
# TODO(jelmer): handle S_ISGITLINK(entry.mode) here
try:
blob = blob_from_path_and_stat(full_path, os.lstat(full_path))
except OSError as e:
Expand All @@ -591,8 +590,19 @@ def get_unstaged_changes(index, root_path):
except IOError as e:
if e.errno != errno.EISDIR:
raise
# The file was changed to a directory, so consider it removed.
yield tree_path
# This is actually a directory
if os.path.exists(os.path.join(tree_path, '.git')):
# Submodule
from dulwich.errors import NotGitRepository
from dulwich.repo import Repo
try:
if entry.sha != Repo(tree_path).head():
yield tree_path
except NotGitRepository:
yield tree_path
else:
# The file was changed to a directory, so consider it removed.
yield tree_path
else:
if blob.id != entry.sha:
yield tree_path
Expand Down

1 comment on commit e174472

@teward
Copy link

@teward teward commented on e174472 Jul 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! Glad to see this is done, now I can use this with submodules instead of my hackish wrapper that uses installed git executables to get around the submodules issue! :)

Please sign in to comment.