From: Phillip Wood <phillip.wood123@gmail.com>
To: Git Mailing List <git@vger.kernel.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH v2] rebase -r: always reword merge -c
Date: Thu, 2 May 2019 11:22:49 +0100 [thread overview]
Message-ID: <20190502102249.9071-1-phillip.wood123@gmail.com> (raw)
In-Reply-To: <a226ffff-212b-d81c-11fd-bb496b84a78d@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>
If a merge can be fast-forwarded then make sure that we still edit the
commit message if the user specifies -c. The implementation follows the
same pattern that is used for ordinary rewords that are fast-forwarded.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
Thanks to Dscho for his comments on v1, I've changed the test as he suggested.
Range-diff:
1: 0532b70644 ! 1: 738799241a rebase -r: always reword merge -c
@@ -40,9 +40,12 @@
+test_expect_success 'fast-forward merge -c still rewords' '
+ git checkout -b fast-forward-merge-c H &&
-+ set_fake_editor &&
-+ FAKE_COMMIT_MESSAGE=edited GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
-+ git rebase -ir @^ &&
++ (
++ set_fake_editor &&
++ FAKE_COMMIT_MESSAGE=edited \
++ GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
++ git rebase -ir @^
++ ) &&
+ echo edited >expected &&
+ git log --pretty=format:%B -1 >actual &&
+ test_cmp expected actual
sequencer.c | 5 +++++
t/t3430-rebase-merges.sh | 13 +++++++++++++
2 files changed, 18 insertions(+)
diff --git a/sequencer.c b/sequencer.c
index 0db410d590..ff8565e7a8 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3248,6 +3248,10 @@ static int do_merge(struct repository *r,
rollback_lock_file(&lock);
ret = fast_forward_to(r, &commit->object.oid,
&head_commit->object.oid, 0, opts);
+ if (flags & TODO_EDIT_MERGE_MSG) {
+ run_commit_flags |= AMEND_MSG;
+ goto fast_forward_edit;
+ }
goto leave_merge;
}
@@ -3351,6 +3355,7 @@ static int do_merge(struct repository *r,
* value (a negative one would indicate that the `merge`
* command needs to be rescheduled).
*/
+ fast_forward_edit:
ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
run_commit_flags);
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index 4c69255ee6..01238d4b6e 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -164,6 +164,19 @@ test_expect_success 'failed `merge <branch>` does not crash' '
grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message
'
+test_expect_success 'fast-forward merge -c still rewords' '
+ git checkout -b fast-forward-merge-c H &&
+ (
+ set_fake_editor &&
+ FAKE_COMMIT_MESSAGE=edited \
+ GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
+ git rebase -ir @^
+ ) &&
+ echo edited >expected &&
+ git log --pretty=format:%B -1 >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'with a branch tip that was cherry-picked already' '
git checkout -b already-upstream master &&
base="$(git rev-parse --verify HEAD)" &&
--
2.21.0
next prev parent reply other threads:[~2019-05-02 10:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 10:33 [PATCH] rebase -r: always reword merge -c Phillip Wood
2019-04-29 16:14 ` Johannes Schindelin
2019-04-30 9:01 ` Phillip Wood
2019-04-30 22:51 ` Johannes Schindelin
2019-05-02 10:22 ` Phillip Wood [this message]
2019-05-03 9:23 ` [PATCH v2] " Johannes Schindelin
2019-05-17 6:56 ` Johannes Schindelin
2019-05-19 1:32 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190502102249.9071-1-phillip.wood123@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).