From 81ad8ffab7be710464d7412e38662f572ecb74b4 Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Mon, 8 Dec 2014 21:50:17 +0100 Subject: [PATCH] Be explicit about when to allow empty commits. Closes #31. --- bandaid.drush.inc | 11 +++++------ bandaid.inc | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bandaid.drush.inc b/bandaid.drush.inc index ad58e7f..f9c70ad 100755 --- a/bandaid.drush.inc +++ b/bandaid.drush.inc @@ -417,7 +417,7 @@ function drush_bandaid_apply($project = NULL) { // Commit local version. Git::add('.', TRUE); - Git::commit("Committing local."); + Git::commit("Committing local.", TRUE); // Create a diff to show the user. $patch = Git::diff($checkout_ref); @@ -449,16 +449,15 @@ function drush_bandaid_apply($project = NULL) { if (Git::apply($project['local_patch_file'])) { drush_log(dt('Patched with @filename.', array('@filename' => basename($project['local_patch_file']))), 'ok'); unlink($project['local_patch_file']); + // Create a commit we can checkout. + Git::add('.'); + Git::commit('Added local patch.'); } else { drush_log(dt('Error applying local patch. Please apply it manually.'), 'error'); } } - // Create a commit we can checkout. - Git::add('.'); - Git::commit('Added patches.'); - // Check out the unmodified local version to the repo. Git::checkout($sha); @@ -778,7 +777,7 @@ function _bandaid_clone_and_tearoff($project) { _bandaid_fix_info_files($checkout_dir); Git::add('.', TRUE); - Git::commit("Committing local."); + Git::commit("Committing local.", TRUE); // Create local patch. $patch = Git::diff('bandaid_patch', 'bandaid_local'); diff --git a/bandaid.inc b/bandaid.inc index c18523c..de04a62 100755 --- a/bandaid.inc +++ b/bandaid.inc @@ -148,8 +148,9 @@ class Git { /** * Commit changes. */ - public static function commit($message) { - return static::exec('git commit --allow-empty -m %s', array($message), 'CANNOT_COMMIT'); + public static function commit($message, $allow_empty = FALSE) { + $allow_empty = $allow_empty ? '--allow-empty' : ''; + return static::exec('git commit %s -m %s', array($allow_empty, $message), 'CANNOT_COMMIT'); } /**