From f7e02d76ec22bda2a0dfcd24f44a4df8544fae02 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 13 Sep 2012 13:25:44 +0100 Subject: morph merge: Don't make a merge commit if only the refs changed 'git commit' fails if there are no changes in any case. --- morphlib/git.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'morphlib/git.py') 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''' -- cgit v1.2.1