Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize is_dirty in dulwich? #81

Closed
skshetry opened this issue May 31, 2022 · 0 comments
Closed

optimize is_dirty in dulwich? #81

skshetry opened this issue May 31, 2022 · 0 comments

Comments

@skshetry
Copy link
Member

I wonder if we should optimize this further, i.e. use generator and return False if there is any changes rather than collecting everything. :)

Something like:

from itertools import chain, zip_longest

with open_repo_closing(repo) as r:
        # 1. Get status of staged
        tracked_changes = get_tree_changes(r)
        # 2. Get status of unstaged
        index = r.open_index()
        normalizer = r.get_blob_normalizer()
        filter_callback = normalizer.checkin_normalize

        unstaged_changes = get_unstaged_changes(index, r.path, filter_callback)
        untracked_paths = get_untracked_paths(
            r.path,
            r.path,
            index,
            exclude_ignored=not ignored,
            untracked_files=untracked_files,
        )
        return any(chain.from_iterable(zip_longest(untracked_paths, unstaged_changes)))

The only doubt that I have is that it won't reuse IgnoreManager, which I think already happens for status.
No strong opinion though, we could also propose this in dulwich.

Originally posted by @skshetry in #74 (comment)

@skshetry skshetry closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant