From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: phillip.wood@dunelm.org.uk
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 2/2] rebase --exec: make it work with --rebase-merges
Date: Thu, 9 Aug 2018 15:30:11 +0200 (DST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1808091529210.71@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <3ccf2fcf-5d58-5d24-7e0b-d1d0e511feaa@talktalk.net>
Hi Phillip,
On Thu, 9 Aug 2018, Phillip Wood wrote:
> On 09/08/18 10:22, Johannes Schindelin wrote:
> >
> > On Mon, 6 Aug 2018, Phillip Wood wrote:
> >
> >> On 06/08/18 10:52, Johannes Schindelin via GitGitGadget wrote:
> >>>
> >>> + else if (is_fixup(command)) {
> >>> + insert = i + 1;
> >>> + continue;
> >>> + }
> >>> + strbuf_insert(buf,
> >>> + todo_list.items[insert].offset_in_buf +
> >>> + offset, commands, commands_len);
> >>> offset += commands_len;
> >>> + insert = -1;
> >>> }
> >>> - first = 0;
> >>> +
> >>> + if (command == TODO_PICK || command == TODO_MERGE)
> >>> + insert = i + 1;
> >>> }
> >>>
> >>> /* append final <commands> */
> >>> - strbuf_add(buf, commands, commands_len);
> >>> + if (insert >= 0 || !offset)
> >>> + strbuf_add(buf, commands, commands_len);
> >>
> >> Having read your other message about this patch I think if you wanted to fix
> >> the position of the final exec in the case where the todo list ends with a
> >> comment you could do something like
> >>
> >> if (insert >= 0)
> >> strbuf_insert(buf,
> >> todo_list.items[insert].offset_in_buf +
> >> offset, commands, commands_len);
> >> else
> >> strbuf_add(buf, commands, commands_len);
> >
> > That does not really work, as `insert` can point *after* the last line, in
> > which case `todo_list.items[insert]` is undefined (and in the worst case,
> > causes a segmentation fault).
>
> Ah, I'd missed that, does changing the conditions to
> if (insert >= 0 && insert < todo.list_nr) and
> else if (insert >=0 || !offset) work?
That's pretty exactly what I did ;-)
Ciao,
Dscho
next prev parent reply other threads:[~2018-08-09 13:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-03 17:42 [PATCH 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin via GitGitGadget
2018-08-03 17:42 ` [PATCH 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-03 17:42 ` [PATCH 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget
2018-08-03 18:28 ` Junio C Hamano
2018-08-06 9:34 ` Johannes Schindelin
2018-08-06 9:50 ` Johannes Schindelin
2018-08-06 15:12 ` Junio C Hamano
2018-08-03 20:26 ` Junio C Hamano
2018-08-06 9:36 ` Johannes Schindelin
2018-08-06 9:52 ` [PATCH v2 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin via GitGitGadget
2018-08-06 9:52 ` [PATCH v2 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-06 9:52 ` [PATCH v2 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget
2018-08-06 15:23 ` Phillip Wood
2018-08-06 16:00 ` Phillip Wood
2018-08-09 9:22 ` Johannes Schindelin
2018-08-09 10:04 ` Phillip Wood
2018-08-09 13:30 ` Johannes Schindelin [this message]
2018-08-06 10:08 ` [PATCH v2 0/2] Make git rebase work with --rebase-merges and --exec Johannes Schindelin
2018-08-09 9:41 ` [PATCH v3 " Johannes Schindelin via GitGitGadget
2018-08-09 9:41 ` [PATCH v3 1/2] t3430: demonstrate what -r, --autosquash & --exec should do Johannes Schindelin via GitGitGadget
2018-08-09 9:41 ` [PATCH v3 2/2] rebase --exec: make it work with --rebase-merges Johannes Schindelin via GitGitGadget
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=nycvar.QRO.7.76.6.1808091529210.71@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--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).