From db8e62315c13b97ff6cebb419042115502229304 Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 7 Apr 2016 11:19:27 -0400 Subject: [PATCH] Defer the callback to the next tick. This gives GitRepository the chance to clear its path cache before the callback is invoked. Otherwise reads from the cached status state within the callback would be wrong. --- src/git-repository.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/git-repository.coffee b/src/git-repository.coffee index 30d99791d..a04124b78 100644 --- a/src/git-repository.coffee +++ b/src/git-repository.coffee @@ -166,7 +166,12 @@ class GitRepository # # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. onDidChangeStatuses: (callback) -> - @async.onDidChangeStatuses callback + @async.onDidChangeStatuses -> + # Defer the callback to the next tick so that we've reset + # `@statusesByPath` by the time it's called. Otherwise reads from within + # the callback could be inconsistent. + # See https://github.com/atom/atom/issues/11396 + process.nextTick callback ### Section: Repository Details