From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.2 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 7F11B1F404 for ; Thu, 19 Apr 2018 12:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbeDSMVA (ORCPT ); Thu, 19 Apr 2018 08:21:00 -0400 Received: from mout.gmx.net ([212.227.17.22]:54367 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751381AbeDSMU7 (ORCPT ); Thu, 19 Apr 2018 08:20:59 -0400 Received: from [192.168.0.129] ([37.201.195.116]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MGRhs-1fDaWx03sG-00DHgt; Thu, 19 Apr 2018 14:20:51 +0200 Date: Thu, 19 Apr 2018 14:20:35 +0200 (DST) From: Johannes Schindelin X-X-Sender: virtualbox@MININT-6BKU6QN.europe.corp.microsoft.com To: git@vger.kernel.org cc: Junio C Hamano , Jacob Keller , Stefan Beller , Philip Oakley , Eric Sunshine , Phillip Wood , Igor Djordjevic , Johannes Sixt , Sergey Organov , =?UTF-8?Q?Martin_=C3=85gren?= Subject: [PATCH v7 06/17] sequencer: introduce new commands to reset the revision In-Reply-To: Message-ID: <77c08b61387057af1be57c2b50769651cc8ec898.1524139900.git.johannes.schindelin@gmx.de> References: User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:oidzsO3m9AywvDDalyW2TvFWzEVFhtpa/6HUZA8fPM91b/2VKaQ 0A1k61hJuB4Z0PF48QtSsplutwkxI64pJc7MqdcRk75/p8M2ffwvgi32ZGJkOXalqOXhn5G WbBUWOodvR3CwWgwxj7V9rM5eeZWvZowGJ9vqqMb5jsIOGFgpe+ytrZBbVWcxtaRdsBzPvi lNMxuxCU6D//PKaaBcyog== X-UI-Out-Filterresults: notjunk:1;V01:K0:f17HLdWqCls=:ndFTSepNfALjSTgo4XPswe Mco+kKH14jSrg7ImcV4eEFAn6XWmttC91Rrwk6xdlLQV6/gPYzWkUkHooQqcYE1RXpd3itryc k3pfkGzi/JIMI8CnpfpnVOC4VO6g2ARm/MVupMfS0NglY3JLx+s8niDVepZM5dvcxOmWEGNSU vhITqSym0UFTgRC0R8V/b9NkAf6LL84VBT9iIySrbkIEp38YBBSOghz3M3Pzjt1ogO4VsCIfE xs0E0s9emZwa6LTGA/bvPRHG5V0LubCes2YKYN/hzBHVJulm5z4VsC2loF6sJe9KnBdfYIGqh O7ROxxODpEWXUQgUo/J3qNJwnOVMJJKvCsNUIjhc7YhpZOI365pjfTldApnuT6pwWc2pvtqKu wmubsAZP3PggVVNPqR5Ds8KzQTxpciVXWZlQaKSUoO+ZdTOkTqVaTQIoqhRou5dKMrQTrxFl3 ASa9rhoj5Was2/KqSaze2G6YGMaa3KI8MxfmTbk61KL8IefExn1cVp8CcyZVOpl29fsj9MJ/t U+lCU575IXhvPCnirUlQJHKAC4JWe9oZ5CFAT+gdEluQxc/jPRC/QzHOARKHRaSowbzZUM9do R6IDuXuE8DB2Cd4Y4BWAZgDMuF/q3E54TK1A0hki0c2I3zZzr4O6xZFd+XdI75WsHB5lqmV1l wEJkc1Ez+ildK6xmo2Golo63l2FPpZrovWMmrq1fyA/pqme+Ztaoi575rJ53mXOQquBBQo7P2 NtuM2831nRxkCisrVT2DIvxQx5YzevydbTq1FDLn48slJRscll3F1xmQ5O2M7lt+AQNG8i5RO clU+UNs5wg/BXFZLYXUv9L9O72CIvfhsmWkVPg+tYtWbQmWQLk= Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the upcoming commits, we will teach the sequencer to rebase merges. This will be done in a very different way from the unfortunate design of `git rebase --preserve-merges` (which does not allow for reordering commits, or changing the branch topology). The main idea is to introduce new todo list commands, to support labeling the current revision with a given name, resetting the current revision to a previous state, and merging labeled revisions. This idea was developed in Git for Windows' Git garden shears (that are used to maintain Git for Windows' "thicket of branches" on top of upstream Git), and this patch is part of the effort to make it available to a wider audience, as well as to make the entire process more robust (by implementing it in a safe and portable language rather than a Unix shell script). This commit implements the commands to label, and to reset to, given revisions. The syntax is: label reset Internally, the `label ` command creates the ref `refs/rewritten/`. This makes it possible to work with the labeled revisions interactively, or in a scripted fashion (e.g. via the todo list command `exec`). These temporary refs are removed upon sequencer_remove_state(), so that even a `git rebase --abort` cleans them up. We disallow '#' as label because that character will be used as separator in the upcoming `merge` command. Later in this patch series, we will mark the `refs/rewritten/` refs as worktree-local, to allow for interactive rebases to be run in parallel in worktrees linked to the same repository. As typos happen, a failed `label` or `reset` command will be rescheduled immediately. Note that this needs a little change in the original code to perform a reschedule: there is no commit from which to generate a patch here (and we will simply fall through to the regular `return res`). We keep that code path, though, because we will use it for the upcoming `merge` command, too. Signed-off-by: Johannes Schindelin --- git-rebase--interactive.sh | 2 + sequencer.c | 201 +++++++++++++++++++++++++++++++++++-- 2 files changed, 196 insertions(+), 7 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index e1b865f43f2..e8d3a7d7588 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -162,6 +162,8 @@ s, squash = use commit, but meld into previous commit f, fixup = like \"squash\", but discard this commit's log message x, exec = run command (the rest of the line) using shell d, drop = remove commit +l, label