From d8a3a9c34be643309b3492fc3a2ba50923ca5ffa Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Tue, 26 Mar 2019 12:10:23 +0000 Subject: [PATCH] batch-rebase: Skip emtpy commits Skip commits that are made empty by a previous equivalent commit instead of failing. --- tools/batch-rebase | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/batch-rebase b/tools/batch-rebase index a7f67a097..9f00240af 100755 --- a/tools/batch-rebase +++ b/tools/batch-rebase @@ -37,6 +37,9 @@ from lisa.conf import SimpleMultiSrcConf, KeyDesc, LevelKeyDesc, TopLevelKeyDesc def info(msg): logging.info(msg) +def warn(msg): + logging.warning(msg) + class BatchRebaseManifest(SimpleMultiSrcConf): """ Configuration of batch-rebase @@ -115,6 +118,15 @@ def has_unresolved(repo): else: return False +def empty_staging_area(repo): + git = make_git_func(repo) + try: + git(['diff', '--quiet', '--exit-code', '--cached']) + except subprocess.CalledProcessError: + return False + else: + return True + def do_create(conf_folder, repo, temp_repo, new_branch, conf, persistent_tags): # Use --shared to avoid copying the git objects, so we only pay for a # checkout @@ -312,8 +324,13 @@ def rerere_autocommit(repo): return False # If rerere did its job, commit and carry on else: - info('Git rerere supplied solution, carrying on') - git(['commit', '--no-edit']) + if empty_staging_area(repo): + # If the commit would be empty, just skip it + warn('Empty commit, skipping it') + git(['reset']) + else: + info('Git rerere supplied solution, carrying on') + git(['commit', '--no-edit']) try: git(['cherry-pick', '--continue']) -- GitLab