Skip to content

Git history view does not remember selected commit if put in background #102

@bpsm

Description

@bpsm

Maybe related to #91.

As far as I can tell, PBGitHistoryController:

  1. refreshes the history view whenever GitX gains focus
  2. tries to restore the selected commit when doing this, but fails.

I poked around in the debugger and found:

- (NSArray *) selectedObjectsForSHA:(NSString *)commitSHA
{
    NSPredicate *selection = [NSPredicate predicateWithFormat:@"sha == %@", commitSHA];
    NSArray *selectedCommits = [[commitController content] filteredArrayUsingPredicate:selection];

    if (([selectedCommits count] == 0) && [self firstCommit])
            selectedCommits = [NSArray arrayWithObject:[self firstCommit]];

    return selectedCommits;
}

We come in with commitSHA equal to some commit e.g. "c2ec9ea..." which exists in the repository and is, in fact, the commit that was selected when the gitx window lost focus.

The NSPredicate looks plausible (I'm a total Cocoa nooob), but [commitController content] is delivering an empty NSArray, so selectedCommits ends up as an empty NSArray. I have no theories on why that could be.

The result of all this is that the list of selected commits comes back empty and PBGitHistoryController improvises by selecting the HEAD of the current branch instead of restoring the last selected commit.

This is absolutely maddening as I've grown accustomed to using gitx to do code reviews, which means a lot of command-tabbing back and forth between gitx and the IDE/Editor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions