Only compute Git status flags once

Previously the status was fetched twice, once for
if modified and once for if new.

Now the flags are fetched once and Git now provides
helpers to check the status flags directly for
modified and new status.
This commit is contained in:
Kevin Sawicki
2013-01-07 17:35:54 -08:00
parent 146ae9d776
commit f5344080f1
3 changed files with 21 additions and 10 deletions

View File

@@ -36,19 +36,25 @@ class Git
isPathIgnored: (path) ->
@repo.isIgnored(@relativize(path))
isPathModified: (path) ->
isStatusModified: (status) ->
modifiedFlags = @statusFlags.working_dir_modified |
@statusFlags.working_dir_delete |
@statusFlags.working_dir_typechange |
@statusFlags.index_modified |
@statusFlags.index_deleted |
@statusFlags.index_typechange
(@getPathStatus(path) & modifiedFlags) > 0
(status & modifiedFlags) > 0
isPathNew: (path) ->
isPathModified: (path) ->
@isStatusModified(@getPathStatus(path))
isStatusNew: (status) ->
newFlags = @statusFlags.working_dir_new |
@statusFlags.index_new
(@getPathStatus(path) & newFlags) > 0
(status & newFlags) > 0
isPathNew: (path) ->
@isStatusNew(@getPathStatus(path))
relativize: (path) ->
workingDirectory = @getWorkingDirectory()