git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] rebase --exec: make it work with --rebase-merges

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 9, 2018, 13:30 UTC
Message-ID
<nycvar.QRO.7.76.6.1808091529210.71@tvgsbejvaqbjf.bet>
In-Reply-To
<3ccf2fcf-5d58-5d24-7e0b-d1d0e511feaa@talktalk.net>
Hi Phillip,
On Thu, 9 Aug 2018, Phillip Wood wrote:
Show 45 quoted lines
> 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

Previous: Phillip WoodNext: Johannes Schindelin
Message 17 of 21 in “Make git rebase work with --rebase-merges and --exec”
  1. 0/2 Make git rebase work with --rebase-merges and --execJohannes Schindelin via GitGitGadget, Aug 3, 2018
  2. 1/2 t3430: demonstrate what -r, --autosquash & --exec should doJohannes Schindelin via GitGitGadget, Aug 3, 2018
  3. 2/2 rebase --exec: make it work with --rebase-mergesJohannes Schindelin via GitGitGadget, Aug 3, 2018
  4. Junio C HamanoAug 3, 2018
  5. Johannes SchindelinAug 6, 2018
  6. Johannes SchindelinAug 6, 2018
  7. Junio C HamanoAug 6, 2018
  8. Junio C HamanoAug 3, 2018
  9. Johannes SchindelinAug 6, 2018
  10. 0/2 Make git rebase work with --rebase-merges and --execJohannes Schindelin via GitGitGadget, Aug 6, 2018
  11. 1/2 t3430: demonstrate what -r, --autosquash & --exec should doJohannes Schindelin via GitGitGadget, Aug 6, 2018
  12. 2/2 rebase --exec: make it work with --rebase-mergesJohannes Schindelin via GitGitGadget, Aug 6, 2018
  13. Phillip WoodAug 6, 2018
  14. Phillip WoodAug 6, 2018
  15. Johannes SchindelinAug 9, 2018
  16. Phillip WoodAug 9, 2018
  17. Johannes SchindelinAug 9, 2018
  18. Johannes SchindelinAug 6, 2018
  19. 0/2 Make git rebase work with --rebase-merges and --execJohannes Schindelin via GitGitGadget, Aug 9, 2018
  20. 1/2 t3430: demonstrate what -r, --autosquash & --exec should doJohannes Schindelin via GitGitGadget, Aug 9, 2018
  21. 2/2 rebase --exec: make it work with --rebase-mergesJohannes Schindelin via GitGitGadget, Aug 9, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.