From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ramkumar Ramachandra Subject: [PATCH 15/18] revert: Remove sequencer state when no commits are pending Date: Thu, 4 Aug 2011 16:09:13 +0530 Message-ID: <1312454356-3070-16-git-send-email-artagnon@gmail.com> References: <1312454356-3070-1-git-send-email-artagnon@gmail.com> Cc: Git List , Jonathan Nieder , Christian Couder , Daniel Barkalow , Jeff King To: Junio C Hamano X-From: git-owner@vger.kernel.org Thu Aug 04 12:43:46 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QovOz-0007PF-Ot for gcvg-git-2@lo.gmane.org; Thu, 04 Aug 2011 12:43:46 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754141Ab1HDKni (ORCPT ); Thu, 4 Aug 2011 06:43:38 -0400 Received: from mail-pz0-f42.google.com ([209.85.210.42]:63604 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753971Ab1HDKnh (ORCPT ); Thu, 4 Aug 2011 06:43:37 -0400 Received: by mail-pz0-f42.google.com with SMTP id 37so1836868pzk.1 for ; Thu, 04 Aug 2011 03:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=uvmbipyPJ9lWL5+qe0NHtiDWzIAtK9KT9HG6TQc/nkM=; b=TDv5F+WQ7gci9cZBBu1miOes4ETUmxg82z8eNrdg/GPW1myNXd49i2eFmgCe8wYRK3 XKUbLWNil+N2iszGnPQtEM6PmyzjRJmKKUsedYZIyrDZT8OENaJcP208iHQw3XqHtE2g MJh5ieEnwo8BDQR+l6kZEdH8vNDvzqu0TJyaU= Received: by 10.142.120.9 with SMTP id s9mr586615wfc.431.1312454617156; Thu, 04 Aug 2011 03:43:37 -0700 (PDT) Received: from localhost.localdomain ([203.110.240.41]) by mx.google.com with ESMTPS id m7sm2090440pbk.6.2011.08.04.03.43.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Aug 2011 03:43:36 -0700 (PDT) X-Mailer: git-send-email 1.7.6.351.gb35ac.dirty In-Reply-To: <1312454356-3070-1-git-send-email-artagnon@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: When cherry-pick or revert is called on a list of commits, and a conflict encountered somewhere in the middle, the data in ".git/sequencer" is required to continue the operation. However, when a conflict is encountered in the very last commit, the user will have to "continue" after resolving the conflict and committing just so that the sequencer state is removed. This is how the current "rebase -i" script works as well. $ git cherry-pick foo..bar ... conflict encountered while picking "bar" ... $ echo "resolved" >problematicfile $ git add problematicfile $ git commit $ git cherry-pick --continue # This would be a no-op Change this so that the sequencer state is cleared when a conflict is encountered in the last commit. Incidentally, this patch makes sure that some existing tests don't break when features like "--reset" and "--continue" are implemented later in the series. A better way to implement this feature is to get the last "git commit" to remove the sequencer state. However, that requires tighter coupling between "git commit" and the sequencer, a goal that can be pursued once the sequencer is made more general. Signed-off-by: Ramkumar Ramachandra Acked-by: Jonathan Nieder Signed-off-by: Jonathan Nieder --- builtin/revert.c | 12 +++++++++++- t/t3510-cherry-pick-sequence.sh | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index a8accd6..000806c 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -763,8 +763,18 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts) for (cur = todo_list; cur; cur = cur->next) { save_todo(cur, opts); res = do_pick_commit(cur->item, opts); - if (res) + if (res) { + if (!cur->next) + /* + * An error was encountered while + * picking the last commit; the + * sequencer state is useless now -- + * the user simply needs to resolve + * the conflict and commit + */ + remove_sequencer_state(0); return res; + } } /* diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index fd69865..a414086 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -82,4 +82,28 @@ test_expect_success '--reset cleans up sequencer state' ' test_path_is_missing .git/sequencer ' +test_expect_success 'cherry-pick cleans up sequencer state when one commit is left' ' + pristine_detach initial && + test_must_fail git cherry-pick base..picked && + test_path_is_missing .git/sequencer && + echo "resolved" >foo && + git add foo && + git commit && + { + git rev-list HEAD | + git diff-tree --root --stdin | + sed "s/$_x40/OBJID/g" + } >actual && + cat >expect <<-\EOF && + OBJID + :100644 100644 OBJID OBJID M foo + OBJID + :100644 100644 OBJID OBJID M unrelated + OBJID + :000000 100644 OBJID OBJID A foo + :000000 100644 OBJID OBJID A unrelated + EOF + test_cmp expect actual +' + test_done -- 1.7.6.351.gb35ac.dirty