From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabian Ruch Subject: [RFC PATCH 3/7] rebase -i: Stop on root commits with empty log messages Date: Thu, 19 Jun 2014 05:28:34 +0200 Message-ID: <53A258E2.501@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Jun 19 05:28:44 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WxT1o-0002z2-47 for gcvg-git-2@plane.gmane.org; Thu, 19 Jun 2014 05:28:44 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756870AbaFSD2j (ORCPT ); Wed, 18 Jun 2014 23:28:39 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:61679 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbaFSD2i (ORCPT ); Wed, 18 Jun 2014 23:28:38 -0400 Received: by mail-wi0-f177.google.com with SMTP id r20so2113914wiv.10 for ; Wed, 18 Jun 2014 20:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=VOPIJHTOeicIByGWja/mwUYHX089xS8QirGUUVgXhWM=; b=Khq1K5kY9x18/AeaKtflwcxKmdW3DWuVnT6rx8aXwcotIM7i4Ohxr4SxdmaIWgiXeW XHfqVAhwRV3uXtCWAWx8elo8hTz8mjpTN522fndi/99wJfDmV/+z47beqjRDUDiXJTij mO9rX18C+1/HlJ3Bdz3+l/eHE+KtlhFYleovf8LN7D7lU7x6fdFQhdMGFjvW/xjWsl2x pYu1+wAss9kmYvEIAcmZXoUtpWNDZfp08xiu9xHYfN4v0XQh7iBvz5xRRHp7cENtTbzH k1knXh3YdcN/A0lkSDZ6jQpsjaoQHhxHWu72MDhYhsCmmgEiDPWEgLzt9UXMVBreFvBH woEw== X-Received: by 10.194.238.65 with SMTP id vi1mr1861072wjc.84.1403148516497; Wed, 18 Jun 2014 20:28:36 -0700 (PDT) Received: from client.googlemail.com (nat-wh-nan.rz.uni-karlsruhe.de. [141.70.81.135]) by mx.google.com with ESMTPSA id o3sm29244879wiz.24.2014.06.18.20.28.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Jun 2014 20:28:35 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: When `rebase` is executed with `--root` but no `--onto` is specified, `rebase` creates a sentinel commit which is replaced with the root commit in three steps. This combination of options results never in a fast-forward. 1. The sentinel commit is forced into the authorship of the root commit. 2. The changes introduced by the root commit are applied to the index but not committed. If this step fails for whatever reason, all commit information will be there and the user can safely run `git-commit --amend` after resolving the problems. 3. The new root commit is created by squashing the changes into the sentinel commit which already carries the authorship of the cherry-picked root commit. The command line used to create the commit in the third step specifies effectless and erroneous options. Remove those. - `--allow-empty-message` is erroneous: If the root's commit message is empty, the rebase shall fail like for any other commit that is on the to-do list and has an empty commit message. Fix the bug that git-rebase does not fail when the initial commit has an empty log message but is replayed using `--root` is specified. Add test. - `-C` is effectless: The commit being amended, which is the sentinel commit, already carries the authorship and log message of the cherry-picked root commit. The committer email and commit date fields are reset either way. After all, if step two fails, `rebase --continue` won't include these flags in the git-commit command line either. Signed-off-by: Fabian Ruch --- git-rebase--interactive.sh | 4 ++-- t/t3412-rebase-root.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index fffdfa5..f09eeae 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -539,8 +539,8 @@ do_pick () { git commit --allow-empty --allow-empty-message --amend \ --no-post-rewrite -n -q -C $1 && pick_one -n $1 && - git commit --allow-empty --allow-empty-message \ - --amend --no-post-rewrite -n -q -C $1 \ + git commit --allow-empty --amend \ + --no-post-rewrite -n -q \ ${gpg_sign_opt:+"$gpg_sign_opt"} || die_with_patch $1 "Could not apply $1... $2" else diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 0b52105..3608db4 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -278,4 +278,43 @@ test_expect_success 'rebase -i -p --root with conflict (second part)' ' test_cmp expect-conflict-p out ' +test_expect_success 'stop rebase --root on empty root log message' ' + # create a root commit with a non-empty tree so that rebase does + # not fail because of an empty commit, and an empty log message + echo root-commit >file && + git add file && + tree=$(git write-tree) && + root=$(git commit-tree $tree file.expected && + test_cmp file file.expected && + git rebase --abort +' + +test_expect_success 'stop rebase --root on empty child log message' ' + # create a root commit with a non-empty tree and provide a log + # message so that rebase does not fail until the root commit is + # successfully replayed + echo root-commit >file && + git add file && + tree=$(git write-tree) && + root=$(git commit-tree $tree -m root-commit) && + git checkout -b no-message-child-commit $root && + # create a child commit with a non-empty patch so that rebase + # does not fail because of an empty commit, but an empty log + # message + echo child-commit >file && + git add file && + git commit --allow-empty-message --no-edit && + # do not ff because otherwise neither the patch nor the message + # are looked at and checked for emptiness + test_must_fail env EDITOR=true git rebase -i --force-rebase --root && + echo child-commit >file.expected && + test_cmp file file.expected && + git rebase --abort +' + test_done -- 2.0.0