Skip to content

Index is refreshed when chunks and files are staged -- is this neccessary? #428

Closed

Description

@dbrnz

I've been trying to understand why gitx wheel spins, sometimes for a few seconds, with Refreshing index... whenever something is staged, and have found:

  1. Index refresh is done by spawning an external task: git update-index -q --unmerged --ignore-missing --refresh.
  2. The refresh is invoked in PBGitCommitController when it sees repository updated events of type WorkingDir and Index. In this case it is the Index event that is responsible for the refresh.
  3. These events are sent by PBGitRepositoryWatcher.
  4. The Index event is generated when the index directory's modification time is changed.

Given that gitx should be able to determine if all of an un-staged file has been staged (and vice-versa) and so update the appropriate lists, is there a need to then refresh the index?

#181 is related.

Activity

  1. dbrnz commented on Jan 1, 2024

    @dbrnz
    Author

    Hmm, with a bit more testing I understand that the index refresh is needed...

    Why though the wheel spin? Is it because of lock contention?

    Commenting out line 126 of PBGitCommitController.m to disable refresh when staged and then using Cmd-R to manually refresh results in a fast refresh, as does running update-index --refresh from the command line, so does the refresh need to be deferred until after the stage/un-stage has finished processing?

  2. goneng commented on Sep 18, 2026

    @goneng
    Collaborator

    Fixed by #547.

    The git update-index -q --unmerged --ignore-missing --refresh spawn you traced no longer runs on the Index and WorkingDir events. It moved to -applicationDidBecomeActive:, so it happens once when the app comes to the front rather than on every FSEvents notification. Staging now takes the internal path only, which is ls-files, diff-index and diff-files, and never takes index.lock.

    To your actual question, whether the refresh is needed at all: it is still wanted, but for a narrower reason than it was being used for. It clears phantom "modified" entries where content matches but mtime does not, which the app cannot work out for itself. Running it once per activation covers that without the contention.

    One thing that did not change: the status bar still reads "Refreshing index..." during the internal refresh, so the old wording can still suggest the old behaviour. Worth a separate issue if it is still misleading in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions