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.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 5D2981F51C for ; Thu, 24 May 2018 11:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969172AbeEXLum (ORCPT ); Thu, 24 May 2018 07:50:42 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:37694 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967076AbeEXLuN (ORCPT ); Thu, 24 May 2018 07:50:13 -0400 Received: by mail-wr0-f174.google.com with SMTP id i12-v6so2567923wrc.4 for ; Thu, 24 May 2018 04:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qxe0oTbWHs+XVC1iPR8qsV2JQFE7Y9JEEbaWBY+P5xY=; b=B3DHlCyzHvEPhIlglqip/sYd5T2x7MoMNV3t5XvXc/uhIpXfY89KjcEmkl899vtfY8 7A4MX2UtWCTaPcMujsFSea8ng3Y8rGozhGNCRHq0WMP7xzX1cRsiWHxU7Ssmvnm0b8I2 fXdxH3Aalsp8sScfy2d9kes33K6Hcaub07vMu4TdhAJZHFQHp7B813PqGLbL6LGw+s1L 2NHOPtudzM29+Mx6Vl9hokOlptMNwIbGsen5dW8K4/GiXpBnCpIKYGXJvxkgv1txUQCB ACw/Lkc+nKdQK/u4vlgrJmXxT9dvS4lAsHuB1XRNfb3zy9MP9W66W2f7iVbe04CWkhTu Lr5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qxe0oTbWHs+XVC1iPR8qsV2JQFE7Y9JEEbaWBY+P5xY=; b=UIcI0TkxcQRmeS681N5/kIVD111srDJZb+tBqlLQI83MSWer0H8fNXv3r6q08UaY8n KMkmzdHphelby6f0vfwj1ZlJ7Vxu18IRNAif4aHpyf1VUkwBbDZoqukt7ttdOTRev9U5 tDV8fYIalJwiUsl3F5G221oEfNP2J6pOf2BtVlF9cecjIuERjE7hQOnAmLLDHvz1UX3E Guq+dtH0glrmNzA5rRkyUqmpxrZhjqBb66IABgph1Lctaqt+hdQlt39PrpsNK61Mwu1w LHaYEoqFtBHbQlluzpdGNhF+X4VB93o0dof+i8Pfi40p9TSim73L4B+PmTKdePy1kmDR Tt3g== X-Gm-Message-State: ALKqPwf2xVDi6wZDQfp1NHGrZZnqdx8hBJT0Pd6OdWjqpdizg/u4SRQ6 vZruOPxvPc892kg8W5YaQftgDyHyaew= X-Google-Smtp-Source: AB8JxZqlezOmAzyZHlliH7U+BnRhWurpX5xM+WdCznBZLHn6RnW0FEuCyP6YurYRQrjwX0XfKeLJJA== X-Received: by 2002:adf:ea84:: with SMTP id s4-v6mr5587883wrm.223.1527162610590; Thu, 24 May 2018 04:50:10 -0700 (PDT) Received: from localhost.localdomain (AToulouse-658-1-38-64.w86-221.abo.wanadoo.fr. [86.221.117.64]) by smtp.googlemail.com with ESMTPSA id o53-v6sm31494264wrc.96.2018.05.24.04.50.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 04:50:09 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Stefan Beller , Christian Couder , Pratik Karki , Johannes Schindelin , phillip.wood@dunelm.org.uk, Wink Saville , Alban Gruin Subject: [GSoC][PATCH v3 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh Date: Thu, 24 May 2018 13:49:55 +0200 Message-Id: <20180524114958.26521-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180524114958.26521-1-alban.gruin@gmail.com> References: <20180522211625.23893-1-alban.gruin@gmail.com> <20180524114958.26521-1-alban.gruin@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This duplicates git-rebase--interactive.sh to git-rebase--preserve-merges.sh. This is done to split -p from -i. No modifications are made to this file here, but any code that is not used by -p will be stripped in the next commit. Signed-off-by: Alban Gruin --- .gitignore | 1 + Makefile | 2 + git-rebase--preserve-merges.sh | 1069 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1072 insertions(+) create mode 100644 git-rebase--preserve-merges.sh diff --git a/.gitignore b/.gitignore index 833ef3b0b..ef4925485 100644 --- a/.gitignore +++ b/.gitignore @@ -117,6 +117,7 @@ /git-rebase--helper /git-rebase--interactive /git-rebase--merge +/git-rebase--preserve-merges /git-receive-pack /git-reflog /git-remote diff --git a/Makefile b/Makefile index 50da82b01..810a0d0f4 100644 --- a/Makefile +++ b/Makefile @@ -582,6 +582,7 @@ SCRIPT_LIB += git-mergetool--lib SCRIPT_LIB += git-parse-remote SCRIPT_LIB += git-rebase--am SCRIPT_LIB += git-rebase--interactive +SCRIPT_LIB += git-rebase--preserve-merges SCRIPT_LIB += git-rebase--merge SCRIPT_LIB += git-sh-setup SCRIPT_LIB += git-sh-i18n @@ -2271,6 +2272,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H) LOCALIZED_SH = $(SCRIPT_SH) LOCALIZED_SH += git-parse-remote.sh LOCALIZED_SH += git-rebase--interactive.sh +LOCALIZED_SH += git-rebase--preserve-merges.sh LOCALIZED_SH += git-sh-setup.sh LOCALIZED_PERL = $(SCRIPT_PERL) diff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh new file mode 100644 index 000000000..2f4941d0f --- /dev/null +++ b/git-rebase--preserve-merges.sh @@ -0,0 +1,1069 @@ +# This shell script fragment is sourced by git-rebase to implement +# its interactive mode. "git rebase --interactive" makes it easy +# to fix up commits in the middle of a series and rearrange commits. +# +# Copyright (c) 2006 Johannes E. Schindelin +# +# The original idea comes from Eric W. Biederman, in +# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/ +# +# The file containing rebase commands, comments, and empty lines. +# This file is created by "git rebase -i" then edited by the user. As +# the lines are processed, they are removed from the front of this +# file and written to the tail of $done. +todo="$state_dir"/git-rebase-todo + +# The rebase command lines that have already been processed. A line +# is moved here when it is first handled, before any associated user +# actions. +done="$state_dir"/done + +# The commit message that is planned to be used for any changes that +# need to be committed following a user interaction. +msg="$state_dir"/message + +# The file into which is accumulated the suggested commit message for +# squash/fixup commands. When the first of a series of squash/fixups +# is seen, the file is created and the commit message from the +# previous commit and from the first squash/fixup commit are written +# to it. The commit message for each subsequent squash/fixup commit +# is appended to the file as it is processed. +# +# The first line of the file is of the form +# # This is a combination of $count commits. +# where $count is the number of commits whose messages have been +# written to the file so far (including the initial "pick" commit). +# Each time that a commit message is processed, this line is read and +# updated. It is deleted just before the combined commit is made. +squash_msg="$state_dir"/message-squash + +# If the current series of squash/fixups has not yet included a squash +# command, then this file exists and holds the commit message of the +# original "pick" commit. (If the series ends without a "squash" +# command, then this can be used as the commit message of the combined +# commit without opening the editor.) +fixup_msg="$state_dir"/message-fixup + +# $rewritten is the name of a directory containing files for each +# commit that is reachable by at least one merge base of $head and +# $upstream. They are not necessarily rewritten, but their children +# might be. This ensures that commits on merged, but otherwise +# unrelated side branches are left alone. (Think "X" in the man page's +# example.) +rewritten="$state_dir"/rewritten + +dropped="$state_dir"/dropped + +end="$state_dir"/end +msgnum="$state_dir"/msgnum + +# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and +# GIT_AUTHOR_DATE that will be used for the commit that is currently +# being rebased. +author_script="$state_dir"/author-script + +# When an "edit" rebase command is being processed, the SHA1 of the +# commit to be edited is recorded in this file. When "git rebase +# --continue" is executed, if there are any staged changes then they +# will be amended to the HEAD commit, but only provided the HEAD +# commit is still the commit to be edited. When any other rebase +# command is processed, this file is deleted. +amend="$state_dir"/amend + +# For the post-rewrite hook, we make a list of rewritten commits and +# their new sha1s. The rewritten-pending list keeps the sha1s of +# commits that have been processed, but not committed yet, +# e.g. because they are waiting for a 'squash' command. +rewritten_list="$state_dir"/rewritten-list +rewritten_pending="$state_dir"/rewritten-pending + +# Work around Git for Windows' Bash whose "read" does not strip CRLF +# and leaves CR at the end instead. +cr=$(printf "\015") + +strategy_args=${strategy:+--strategy=$strategy} +test -n "$strategy_opts" && +eval ' + for strategy_opt in '"$strategy_opts"' + do + strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")" + done +' + +GIT_CHERRY_PICK_HELP="$resolvemsg" +export GIT_CHERRY_PICK_HELP + +comment_char=$(git config --get core.commentchar 2>/dev/null) +case "$comment_char" in +'' | auto) + comment_char="#" + ;; +?) + ;; +*) + comment_char=$(echo "$comment_char" | cut -c1) + ;; +esac + +warn () { + printf '%s\n' "$*" >&2 +} + +# Output the commit message for the specified commit. +commit_message () { + git cat-file commit "$1" | sed "1,/^$/d" +} + +orig_reflog_action="$GIT_REFLOG_ACTION" + +comment_for_reflog () { + case "$orig_reflog_action" in + ''|rebase*) + GIT_REFLOG_ACTION="rebase -i ($1)" + export GIT_REFLOG_ACTION + ;; + esac +} + +last_count= +mark_action_done () { + sed -e 1q < "$todo" >> "$done" + sed -e 1d < "$todo" >> "$todo".new + mv -f "$todo".new "$todo" + new_count=$(( $(git stripspace --strip-comments <"$done" | wc -l) )) + echo $new_count >"$msgnum" + total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l))) + echo $total >"$end" + if test "$last_count" != "$new_count" + then + last_count=$new_count + eval_gettext "Rebasing (\$new_count/\$total)"; printf "\r" + test -z "$verbose" || echo + fi +} + +# Put the last action marked done at the beginning of the todo list +# again. If there has not been an action marked done yet, leave the list of +# items on the todo list unchanged. +reschedule_last_action () { + tail -n 1 "$done" | cat - "$todo" >"$todo".new + sed -e \$d <"$done" >"$done".new + mv -f "$todo".new "$todo" + mv -f "$done".new "$done" +} + +append_todo_help () { + gettext " +Commands: +p, pick = use commit +r, reword = use commit, but edit the commit message +e, edit = use commit, but stop for amending +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