summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 13:25:44 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-14 19:45:01 +0100
commitf7e02d76ec22bda2a0dfcd24f44a4df8544fae02 (patch)
tree23ae6933053f3917346976f878a317f749b939b7 /morphlib/git.py
parent3911c0bea5654a4de7cd9121d89c7f9bc69b0172 (diff)
downloadmorph-f7e02d76ec22bda2a0dfcd24f44a4df8544fae02.tar.gz
morph merge: Don't make a merge commit if only the refs changed
'git commit' fails if there are no changes in any case.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index 9ab98ad0..5862ef9b 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -196,6 +196,17 @@ def checkout_ref(runcmd, gitdir, ref):
'''Checks out a specific ref/SHA1 in a git working tree.'''
runcmd(['git', 'checkout', ref], cwd=gitdir)
+
+def index_has_changes(runcmd, gitdir):
+ '''Returns True if there are no staged changes to commit'''
+ try:
+ runcmd(['git', 'diff-index', '--cached', '--quiet',
+ '--ignore-submodules', 'HEAD'], cwd=gitdir)
+ except cliapp.AppException:
+ return True
+ return False
+
+
def reset_workdir(runcmd, gitdir):
'''Removes any differences between the current commit '''
'''and the status of the working directory'''