From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH 2/3] sequencer: leave a tell-tale when a fixup/squash failed
Date: Fri, 20 Apr 2018 14:18:13 +0200 (DST) [thread overview]
Message-ID: <4f87b8ea2c47b45107e2ba1cdd6d04a66fea0d16.1524226637.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1524226637.git.johannes.schindelin@gmx.de>
In the upcoming patch to clean up fixup/squash commit messages even when
skipping a final fixup/squash that failed with merge conflicts, we will
need to have some indicator what happened.
As we need to remove the message-fixup and message-squash files upon
failure, we cannot use those. So let's just write an explicit amend-type
file, containing either `fixup` or `squash`. The absence of that file
indicates that the we were not in the middle of a fixup or squash when
merge conflicts were happening.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
sequencer.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index 667f35ebdff..a9c3bc26f84 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -106,6 +106,13 @@ static GIT_PATH_FUNC(rebase_path_author_script, "rebase-merge/author-script")
* command is processed, this file is deleted.
*/
static GIT_PATH_FUNC(rebase_path_amend, "rebase-merge/amend")
+/*
+ * If there was a merge conflict in a fixup/squash series, we need to
+ * record the type so that a `git rebase --skip` can clean up the commit
+ * message as appropriate. This file will contain that type (`fixup` or
+ * `squash`), and not exist otherwise.
+ */
+static GIT_PATH_FUNC(rebase_path_amend_type, "rebase-merge/amend-type")
/*
* When we stop at a given patch via the "edit" command, this file contains
* the abbreviated commit name of the corresponding patch.
@@ -2392,10 +2399,20 @@ static int error_with_patch(struct commit *commit,
static int error_failed_squash(struct commit *commit,
struct replay_opts *opts, int subject_len, const char *subject)
{
+ const char *amend_type = "squash";
+
+ if (file_exists(rebase_path_fixup_msg())) {
+ unlink(rebase_path_fixup_msg());
+ amend_type = "fixup";
+ }
+ if (write_message(amend_type, strlen(amend_type),
+ rebase_path_amend_type(), 0))
+ return error(_("could not write '%s'"),
+ rebase_path_amend_type());
+
if (rename(rebase_path_squash_msg(), rebase_path_message()))
return error(_("could not rename '%s' to '%s'"),
rebase_path_squash_msg(), rebase_path_message());
- unlink(rebase_path_fixup_msg());
unlink(git_path_merge_msg());
if (copy_file(git_path_merge_msg(), rebase_path_message(), 0666))
return error(_("could not copy '%s' to '%s'"),
@@ -2572,6 +2589,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
unlink(rebase_path_author_script());
unlink(rebase_path_stopped_sha());
unlink(rebase_path_amend());
+ unlink(rebase_path_amend_type());
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
}
if (item->command <= TODO_SQUASH) {
@@ -2799,6 +2817,7 @@ static int commit_staged_changes(struct replay_opts *opts)
if (run_git_commit(rebase_path_message(), opts, flags))
return error(_("could not commit staged changes."));
unlink(rebase_path_amend());
+ unlink(rebase_path_amend_type());
return 0;
}
--
2.17.0.windows.1.15.gaa56ade3205
next prev parent reply other threads:[~2018-04-20 12:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 12:17 [PATCH 0/3] rebase -i: avoid stale "# This is a combination of" in commit messages Johannes Schindelin
2018-04-20 12:17 ` [PATCH 1/3] rebase -i: demonstrate bug with fixup!/squash! " Johannes Schindelin
2018-04-20 16:40 ` Stefan Beller
2018-04-20 20:04 ` Johannes Schindelin
2018-04-20 20:38 ` Johannes Schindelin
2018-04-20 20:44 ` Stefan Beller
2018-04-20 21:05 ` Johannes Schindelin
2018-04-20 19:29 ` Eric Sunshine
2018-04-20 19:31 ` Eric Sunshine
2018-04-20 20:52 ` Johannes Schindelin
2018-04-20 12:18 ` Johannes Schindelin [this message]
2018-04-20 19:34 ` [PATCH 2/3] sequencer: leave a tell-tale when a fixup/squash failed Eric Sunshine
2018-04-20 12:18 ` [PATCH 3/3] rebase --skip: clean up commit message after a failed fixup/squash Johannes Schindelin
2018-04-21 15:42 ` [PATCH 3/3] rebase --skip: clean up commit message after a failedfixup/squash Phillip Wood
2018-04-27 21:36 ` Johannes Schindelin
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=4f87b8ea2c47b45107e2ba1cdd6d04a66fea0d16.1524226637.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/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).