Skip to content

Commit

Permalink
uncommitted_changes(): new function
Browse files Browse the repository at this point in the history
New function, extracted from require_clean_work_tree().
  • Loading branch information
mhagger committed Apr 19, 2016
1 parent 321d7f0 commit fd3b56a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions git-imerge
Expand Up @@ -309,6 +309,19 @@ def unstaged_changes():
return True


def uncommitted_changes():
"""Return True iff the index contains uncommitted changes."""

try:
check_call([
'git', 'diff-index', '--cached', '--quiet',
'--ignore-submodules', 'HEAD', '--',
])
return False
except CalledProcessError:
return True


def require_clean_work_tree(action):
"""Verify that the current tree is clean.
Expand All @@ -330,12 +343,7 @@ def require_clean_work_tree(action):
if unstaged_changes():
error.append('Cannot %s: You have unstaged changes.' % (action,))

try:
check_call([
'git', 'diff-index', '--cached', '--quiet',
'--ignore-submodules', 'HEAD', '--',
])
except CalledProcessError:
if uncommitted_changes():
if not error:
error.append('Cannot %s: Your index contains uncommitted changes.' % (action,))
else:
Expand Down

0 comments on commit fd3b56a

Please sign in to comment.