Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharvi Mendiratta <charvi077@gmail.com>2021-01-29 21:20:49 +0300
committerJunio C Hamano <gitster@pobox.com>2021-01-30 02:21:56 +0300
commitbae5b4aea523388faedd3b850c862fe45198c6b2 (patch)
tree4a8ce59e854fa06df5a17c5f69f3493643673b10 /sequencer.c
parent1d410cd8c25978c1591a7d35c9077745146c6129 (diff)
rebase -i: teach --autosquash to work with amend!
If the commit subject starts with "amend!" then rearrange it like a "fixup!" commit and replace `pick` command with `fixup -C` command, which is used to fixup up the content if any and replaces the original commit message with amend! commit's message. Original-patch-by: Phillip Wood <phillip.wood@dunelm.org.uk> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sequencer.c b/sequencer.c
index 46e11d20e8..d09ce446b6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5662,6 +5662,12 @@ static int subject2item_cmp(const void *fndata,
define_commit_slab(commit_todo_item, struct todo_item *);
+static inline int skip_fixup_amend_squash(const char *subject, const char **p) {
+ return skip_prefix(subject, "fixup! ", p) ||
+ skip_prefix(subject, "amend! ", p) ||
+ skip_prefix(subject, "squash! ", p);
+}
+
/*
* Rearrange the todo list that has both "pick commit-id msg" and "pick
* commit-id fixup!/squash! msg" in it so that the latter is put immediately
@@ -5720,15 +5726,13 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
format_subject(&buf, subject, " ");
subject = subjects[i] = strbuf_detach(&buf, &subject_len);
unuse_commit_buffer(item->commit, commit_buffer);
- if ((skip_prefix(subject, "fixup! ", &p) ||
- skip_prefix(subject, "squash! ", &p))) {
+ if (skip_fixup_amend_squash(subject, &p)) {
struct commit *commit2;
for (;;) {
while (isspace(*p))
p++;
- if (!skip_prefix(p, "fixup! ", &p) &&
- !skip_prefix(p, "squash! ", &p))
+ if (!skip_fixup_amend_squash(p, &p))
break;
}
@@ -5758,9 +5762,14 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
}
if (i2 >= 0) {
rearranged = 1;
- todo_list->items[i].command =
- starts_with(subject, "fixup!") ?
- TODO_FIXUP : TODO_SQUASH;
+ if (starts_with(subject, "fixup!")) {
+ todo_list->items[i].command = TODO_FIXUP;
+ } else if (starts_with(subject, "amend!")) {
+ todo_list->items[i].command = TODO_FIXUP;
+ todo_list->items[i].flags = TODO_REPLACE_FIXUP_MSG;
+ } else {
+ todo_list->items[i].command = TODO_SQUASH;
+ }
if (tail[i2] < 0) {
next[i] = next[i2];
next[i2] = i;