- if files_here:
- __run('git-update-cache --', files_here)
- if files_gone:
- __run('git-update-cache --remove --', files_gone)
+ # check for unresolved conflicts
+ if not force and [x for x in cache_files
+ if x[0] not in ['M', 'N', 'A', 'D']]:
+ raise GitException, 'Updating cache failed: unresolved conflicts'
+
+ # update the cache
+ add_files = [x[1] for x in cache_files if x[0] in ['N', 'A']]
+ rm_files = [x[1] for x in cache_files if x[0] in ['D']]
+ m_files = [x[1] for x in cache_files if x[0] in ['M']]
+
+ if add_files and __run('git-update-cache --add --', add_files) != 0:
+ raise GitException, 'Failed git-update-cache --add'
+ if rm_files and __run('git-update-cache --force-remove --', rm_files) != 0:
+ raise GitException, 'Failed git-update-cache --rm'
+ if m_files and __run('git-update-cache --', m_files) != 0:
+ raise GitException, 'Failed git-update-cache'
+
+ return True